Search in sources :

Example 56 with COSBase

use of com.tom_roush.pdfbox.cos.COSBase in project PdfBox-Android by TomRoush.

the class PDType3Font method getCharProc.

/**
 * Returns the stream of the glyph for the given character code
 *
 * @param code character code
 * @return the stream to be used to render the glyph
 */
public PDType3CharProc getCharProc(int code) {
    String name = getEncoding().getName(code);
    COSBase base = getCharProcs().getDictionaryObject(COSName.getPDFName(name));
    if (base instanceof COSStream) {
        return new PDType3CharProc(this, (COSStream) base);
    }
    return null;
}
Also used : COSStream(com.tom_roush.pdfbox.cos.COSStream) COSBase(com.tom_roush.pdfbox.cos.COSBase)

Example 57 with COSBase

use of com.tom_roush.pdfbox.cos.COSBase in project PdfBox-Android by TomRoush.

the class PDType3Font method getFontBBox.

/**
 * This will get the fonts bounding box from its dictionary.
 *
 * @return The fonts bounding box.
 */
public PDRectangle getFontBBox() {
    COSBase base = dict.getDictionaryObject(COSName.FONT_BBOX);
    PDRectangle retval = null;
    if (base instanceof COSArray) {
        retval = new PDRectangle((COSArray) base);
    }
    return retval;
}
Also used : COSArray(com.tom_roush.pdfbox.cos.COSArray) COSBase(com.tom_roush.pdfbox.cos.COSBase) PDRectangle(com.tom_roush.pdfbox.pdmodel.common.PDRectangle)

Example 58 with COSBase

use of com.tom_roush.pdfbox.cos.COSBase in project PdfBox-Android by TomRoush.

the class PDFontDescriptor method getFontFile.

/**
 * A stream containing a Type 1 font program.
 *
 * @return A stream containing a Type 1 font program.
 */
public PDStream getFontFile() {
    PDStream retval = null;
    COSBase obj = dic.getDictionaryObject(COSName.FONT_FILE);
    if (obj instanceof COSStream) {
        retval = new PDStream((COSStream) obj);
    }
    return retval;
}
Also used : COSStream(com.tom_roush.pdfbox.cos.COSStream) COSBase(com.tom_roush.pdfbox.cos.COSBase) PDStream(com.tom_roush.pdfbox.pdmodel.common.PDStream)

Example 59 with COSBase

use of com.tom_roush.pdfbox.cos.COSBase in project PdfBox-Android by TomRoush.

the class PDCIDFont method readWidths.

private void readWidths() {
    widths = new HashMap<Integer, Float>();
    COSBase wBase = dict.getDictionaryObject(COSName.W);
    if (wBase instanceof COSArray) {
        COSArray wArray = (COSArray) wBase;
        int size = wArray.size();
        int counter = 0;
        while (counter < size) {
            COSNumber firstCode = (COSNumber) wArray.getObject(counter++);
            COSBase next = wArray.getObject(counter++);
            if (next instanceof COSArray) {
                COSArray array = (COSArray) next;
                int startRange = firstCode.intValue();
                int arraySize = array.size();
                for (int i = 0; i < arraySize; i++) {
                    COSNumber width = (COSNumber) array.getObject(i);
                    widths.put(startRange + i, width.floatValue());
                }
            } else {
                COSNumber secondCode = (COSNumber) next;
                COSNumber rangeWidth = (COSNumber) wArray.getObject(counter++);
                int startRange = firstCode.intValue();
                int endRange = secondCode.intValue();
                float width = rangeWidth.floatValue();
                for (int i = startRange; i <= endRange; i++) {
                    widths.put(i, width);
                }
            }
        }
    }
}
Also used : COSArray(com.tom_roush.pdfbox.cos.COSArray) COSNumber(com.tom_roush.pdfbox.cos.COSNumber) COSBase(com.tom_roush.pdfbox.cos.COSBase)

Example 60 with COSBase

use of com.tom_roush.pdfbox.cos.COSBase in project PdfBox-Android by TomRoush.

the class MergeAcroFormsTest method compareFieldProperties.

private void compareFieldProperties(PDField sourceField, PDField toBeComapredField) {
    // List of keys for comparison
    // Don't include too complex properties such as AP as this will fail the test because
    // of a stack overflow when
    final String[] keys = { "FT", "T", "TU", "TM", "Ff", "V", "DV", "Opts", "TI", "I", "Rect", "DA" };
    COSDictionary sourceFieldCos = sourceField.getCOSObject();
    COSDictionary toBeComparedCos = toBeComapredField.getCOSObject();
    for (String key : keys) {
        COSBase sourceBase = sourceFieldCos.getDictionaryObject(key);
        COSBase toBeComparedBase = toBeComparedCos.getDictionaryObject(key);
        if (sourceBase != null) {
            assertEquals("The content of the field properties shall be the same", sourceBase.toString(), toBeComparedBase.toString());
        } else {
            assertNull("If the source property is null the compared property shall be null too", toBeComparedBase);
        }
    }
}
Also used : COSDictionary(com.tom_roush.pdfbox.cos.COSDictionary) COSBase(com.tom_roush.pdfbox.cos.COSBase)

Aggregations

COSBase (com.tom_roush.pdfbox.cos.COSBase)215 COSArray (com.tom_roush.pdfbox.cos.COSArray)108 COSDictionary (com.tom_roush.pdfbox.cos.COSDictionary)68 COSName (com.tom_roush.pdfbox.cos.COSName)50 COSObject (com.tom_roush.pdfbox.cos.COSObject)42 IOException (java.io.IOException)34 COSString (com.tom_roush.pdfbox.cos.COSString)33 COSNumber (com.tom_roush.pdfbox.cos.COSNumber)29 ArrayList (java.util.ArrayList)29 COSStream (com.tom_roush.pdfbox.cos.COSStream)20 COSArrayList (com.tom_roush.pdfbox.pdmodel.common.COSArrayList)14 MissingOperandException (com.tom_roush.pdfbox.contentstream.operator.MissingOperandException)11 HashMap (java.util.HashMap)11 COSInteger (com.tom_roush.pdfbox.cos.COSInteger)10 Map (java.util.Map)10 List (java.util.List)9 Operator (com.tom_roush.pdfbox.contentstream.operator.Operator)8 COSFloat (com.tom_roush.pdfbox.cos.COSFloat)7 COSObjectKey (com.tom_roush.pdfbox.cos.COSObjectKey)7 PDFStreamParser (com.tom_roush.pdfbox.pdfparser.PDFStreamParser)6