Search in sources :

Example 46 with COSNumber

use of org.apache.pdfbox.cos.COSNumber in project pdfbox by apache.

the class PDType3CharProc method getGlyphBBox.

/**
 * Calculate the bounding box of this glyph. This will work only if the first operator in the
 * stream is d1.
 *
 * @return the bounding box of this glyph, or null if the first operator is not d1.
 * @throws IOException If an io error occurs while parsing the stream.
 */
public PDRectangle getGlyphBBox() throws IOException {
    List<COSBase> arguments = new ArrayList<>();
    PDFStreamParser parser = new PDFStreamParser(this);
    Object token = parser.parseNextToken();
    while (token != null) {
        if (token instanceof COSObject) {
            arguments.add(((COSObject) token).getObject());
        } else if (token instanceof Operator) {
            if (((Operator) token).getName().equals("d1") && arguments.size() == 6) {
                for (int i = 0; i < 6; ++i) {
                    if (!(arguments.get(i) instanceof COSNumber)) {
                        return null;
                    }
                }
                return new PDRectangle(((COSNumber) arguments.get(2)).floatValue(), ((COSNumber) arguments.get(3)).floatValue(), ((COSNumber) arguments.get(4)).floatValue() - ((COSNumber) arguments.get(2)).floatValue(), ((COSNumber) arguments.get(5)).floatValue() - ((COSNumber) arguments.get(3)).floatValue());
            } else {
                return null;
            }
        } else {
            arguments.add((COSBase) token);
        }
        token = parser.parseNextToken();
    }
    return null;
}
Also used : Operator(org.apache.pdfbox.contentstream.operator.Operator) PDFStreamParser(org.apache.pdfbox.pdfparser.PDFStreamParser) COSObject(org.apache.pdfbox.cos.COSObject) ArrayList(java.util.ArrayList) COSNumber(org.apache.pdfbox.cos.COSNumber) COSBase(org.apache.pdfbox.cos.COSBase) COSObject(org.apache.pdfbox.cos.COSObject) PDRectangle(org.apache.pdfbox.pdmodel.common.PDRectangle)

Example 47 with COSNumber

use of org.apache.pdfbox.cos.COSNumber in project pdfbox by apache.

the class FDFField method getClearFieldFlags.

/**
 * This will get the ClrFf entry of the cos dictionary. If it it not present then this method will return null.
 *
 * @return The field flags.
 */
public Integer getClearFieldFlags() {
    Integer retval = null;
    COSNumber ff = (COSNumber) field.getDictionaryObject(COSName.CLR_FF);
    if (ff != null) {
        retval = ff.intValue();
    }
    return retval;
}
Also used : COSInteger(org.apache.pdfbox.cos.COSInteger) COSNumber(org.apache.pdfbox.cos.COSNumber)

Example 48 with COSNumber

use of org.apache.pdfbox.cos.COSNumber in project pdfbox by apache.

the class FDFField method getSetFieldFlags.

/**
 * This will get the SetFf entry of the cos dictionary. If it it not present then this method will return null.
 *
 * @return The field flags.
 */
public Integer getSetFieldFlags() {
    Integer retval = null;
    COSNumber ff = (COSNumber) field.getDictionaryObject(COSName.SET_FF);
    if (ff != null) {
        retval = ff.intValue();
    }
    return retval;
}
Also used : COSInteger(org.apache.pdfbox.cos.COSInteger) COSNumber(org.apache.pdfbox.cos.COSNumber)

Example 49 with COSNumber

use of org.apache.pdfbox.cos.COSNumber in project pdfbox by apache.

the class FDFField method getFieldFlags.

/**
 * This will get the Ff entry of the cos dictionary. If it it not present then this method will return null.
 *
 * @return The field flags.
 */
public Integer getFieldFlags() {
    Integer retval = null;
    COSNumber ff = (COSNumber) field.getDictionaryObject(COSName.FF);
    if (ff != null) {
        retval = ff.intValue();
    }
    return retval;
}
Also used : COSInteger(org.apache.pdfbox.cos.COSInteger) COSNumber(org.apache.pdfbox.cos.COSNumber)

Example 50 with COSNumber

use of org.apache.pdfbox.cos.COSNumber in project pdfbox by apache.

the class FDFField method getClearWidgetFieldFlags.

/**
 * This will get the ClrF entry of the cos dictionary. If it it not present then this method will return null.
 *
 * @return The widget field flags.
 */
public Integer getClearWidgetFieldFlags() {
    Integer retval = null;
    COSNumber ff = (COSNumber) field.getDictionaryObject(COSName.CLR_F);
    if (ff != null) {
        retval = ff.intValue();
    }
    return retval;
}
Also used : COSInteger(org.apache.pdfbox.cos.COSInteger) COSNumber(org.apache.pdfbox.cos.COSNumber)

Aggregations

COSNumber (org.apache.pdfbox.cos.COSNumber)61 COSBase (org.apache.pdfbox.cos.COSBase)29 MissingOperandException (org.apache.pdfbox.contentstream.operator.MissingOperandException)18 COSArray (org.apache.pdfbox.cos.COSArray)18 COSInteger (org.apache.pdfbox.cos.COSInteger)10 Point2D (java.awt.geom.Point2D)6 IOException (java.io.IOException)6 COSObject (org.apache.pdfbox.cos.COSObject)5 PDBorderStyleDictionary (org.apache.pdfbox.pdmodel.interactive.annotation.PDBorderStyleDictionary)5 ArrayList (java.util.ArrayList)4 COSDictionary (org.apache.pdfbox.cos.COSDictionary)4 COSName (org.apache.pdfbox.cos.COSName)4 COSObjectKey (org.apache.pdfbox.cos.COSObjectKey)4 PDFont (org.apache.pdfbox.pdmodel.font.PDFont)4 COSFloat (org.apache.pdfbox.cos.COSFloat)3 COSStream (org.apache.pdfbox.cos.COSStream)2 PDRectangle (org.apache.pdfbox.pdmodel.common.PDRectangle)2 ValidationError (org.apache.pdfbox.preflight.ValidationResult.ValidationError)2 Matrix (org.apache.pdfbox.util.Matrix)2 Paint (java.awt.Paint)1