Example usage for org.apache.pdfbox.cos COSName DESCENDANT_FONTS

List of usage examples for org.apache.pdfbox.cos COSName DESCENDANT_FONTS

Introduction

In this page you can find the example usage for org.apache.pdfbox.cos COSName DESCENDANT_FONTS.

Prototype

COSName DESCENDANT_FONTS

To view the source code for org.apache.pdfbox.cos COSName DESCENDANT_FONTS.

Click Source Link

Usage

From source file:org.xmlcml.font.NonStandardFontManager.java

License:Apache License

private AMIFont lookupOrCreateFont(int level, COSDictionary dict) {
    /**/*ww  w.  jav  a2s .  com*/
    Type = COSName{Font}
    Subtype = COSName{Type1}
    BaseFont = COSName{Times-Roman}
    Name = COSName{arXivStAmP}      
    LastChar = COSInt{32}
    Widths = COSArray{[COSInt{19}]}
    FirstChar = COSInt{32}
    FontMatrix = COSArray{[COSFloat{0.0121}, COSInt{0}, COSInt{0}, COSFloat{-0.0121}, COSInt{0}, COSInt{0}]}
    ToUnicode = COSDictionary{(COSName{Length}:COSInt{212}) (COSName{Filter}:COSName{FlateDecode}) }
    FontBBox = COSArray{[COSInt{0}, COSInt{0}, COSInt{1}, COSInt{1}]}
    Resources = COSDictionary{(COSName{ProcSet}:COSArray{[COSName{PDF}, COSName{ImageB}]}) }
    Encoding = COSDictionary{(COSName{Differences}:COSArray{[COSInt{32}, COSName{space}]}) (COSName{Type}:COSName{Encoding}) }
    CharProcs = COSDictionary{(COSName{space}:COSDictionary{(COSName{Length}:COSInt{67}) (COSName{Filter}:COSName{FlateDecode}) }) }*/

    AMIFont amiFont = null;
    String fontName = AMIFont.getFontName(dict);

    String typeS = null;
    amiFont = getAmiFontByFontName(fontName);
    if (amiFont == null) {
        // some confusion here between fontName and fontFamilyName
        amiFont = new AMIFont(fontName, null, typeS, dict);
        amiFont.setFontName(fontName);
        amiFontByFontNameMap.put(fontName, amiFont);

        String indent = "";
        for (int i = 0; i < level; i++) {
            indent += " ";
        }

        LOG.debug(String.format("%s****************** level %d font dict:", indent, level));

        level++;
        indent += "    ";

        for (COSName key : dict.keySet()) {
            String keyName = key.getName();
            Object object = dict.getDictionaryObject(key);
            LOG.debug(String.format("%s****************** %s = %s", indent, keyName, object));
        }

        COSArray array = (COSArray) dict.getDictionaryObject(COSName.DESCENDANT_FONTS);
        if (array != null) {
            LOG.debug(String.format("%s****************** descendant fonts (%d):", indent, array.size()));
            amiFont = lookupOrCreateFont(level, (COSDictionary) array.getObject(0));
        }
    }
    return amiFont;
}

From source file:org.xmlcml.pdf2svg.AMIFont.java

License:Apache License

public static PDFont getFirstDescendantFont(PDFont pdFont) {
    COSDictionary dict = (COSDictionary) pdFont.getCOSObject();
    COSArray array = dict == null ? null : (COSArray) dict.getDictionaryObject(COSName.DESCENDANT_FONTS);
    PDFont descendantFont = null;/*from   www .  j a  va 2s  .  co m*/
    try {
        descendantFont = array == null ? null : PDFontFactory.createFont((COSDictionary) array.getObject(0));
    } catch (IOException e) {
        LOG.error("****************** Can't create descendant font! for " + pdFont);
    }
    return descendantFont;
}