Search in sources :

Example 16 with COSNumber

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

the class FDFField method getWidgetFieldFlags.

/**
 * This will get the F entry of the cos dictionary. If it it not present then this method will return null.
 *
 * @return The widget field flags.
 */
public Integer getWidgetFieldFlags() {
    Integer retval = null;
    COSNumber f = (COSNumber) field.getDictionaryObject("F");
    if (f != null) {
        retval = f.intValue();
    }
    return retval;
}
Also used : COSInteger(com.tom_roush.pdfbox.cos.COSInteger) COSNumber(com.tom_roush.pdfbox.cos.COSNumber)

Example 17 with COSNumber

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

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(com.tom_roush.pdfbox.cos.COSInteger) COSNumber(com.tom_roush.pdfbox.cos.COSNumber)

Example 18 with COSNumber

use of com.tom_roush.pdfbox.cos.COSNumber 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 19 with COSNumber

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

the class AppendRectangleToPath method process.

@Override
public void process(Operator operator, List<COSBase> operands) throws IOException {
    if (operands.size() < 4) {
        throw new MissingOperandException(operator, operands);
    }
    if (!checkArrayTypesClass(operands, COSNumber.class)) {
        return;
    }
    COSNumber x = (COSNumber) operands.get(0);
    COSNumber y = (COSNumber) operands.get(1);
    COSNumber w = (COSNumber) operands.get(2);
    COSNumber h = (COSNumber) operands.get(3);
    float x1 = x.floatValue();
    float y1 = y.floatValue();
    // create a pair of coordinates for the transformation
    float x2 = w.floatValue() + x1;
    float y2 = h.floatValue() + y1;
    PointF p0 = context.transformedPoint(x1, y1);
    PointF p1 = context.transformedPoint(x2, y1);
    PointF p2 = context.transformedPoint(x2, y2);
    PointF p3 = context.transformedPoint(x1, y2);
    context.appendRectangle(p0, p1, p2, p3);
}
Also used : MissingOperandException(com.tom_roush.pdfbox.contentstream.operator.MissingOperandException) PointF(android.graphics.PointF) COSNumber(com.tom_roush.pdfbox.cos.COSNumber)

Example 20 with COSNumber

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

the class CurveTo method process.

@Override
public void process(Operator operator, List<COSBase> operands) throws IOException {
    if (operands.size() < 6) {
        throw new MissingOperandException(operator, operands);
    }
    if (!checkArrayTypesClass(operands, COSNumber.class)) {
        return;
    }
    COSNumber x1 = (COSNumber) operands.get(0);
    COSNumber y1 = (COSNumber) operands.get(1);
    COSNumber x2 = (COSNumber) operands.get(2);
    COSNumber y2 = (COSNumber) operands.get(3);
    COSNumber x3 = (COSNumber) operands.get(4);
    COSNumber y3 = (COSNumber) operands.get(5);
    PointF point1 = context.transformedPoint(x1.floatValue(), y1.floatValue());
    PointF point2 = context.transformedPoint(x2.floatValue(), y2.floatValue());
    PointF point3 = context.transformedPoint(x3.floatValue(), y3.floatValue());
    if (context.getCurrentPoint() == null) {
        Log.w("PdfBox-Android", "curveTo (" + point3.x + "," + point3.y + ") without initial MoveTo");
        context.moveTo(point3.x, point3.y);
    } else {
        context.curveTo(point1.x, point1.y, point2.x, point2.y, point3.x, point3.y);
    }
}
Also used : MissingOperandException(com.tom_roush.pdfbox.contentstream.operator.MissingOperandException) PointF(android.graphics.PointF) COSNumber(com.tom_roush.pdfbox.cos.COSNumber)

Aggregations

COSNumber (com.tom_roush.pdfbox.cos.COSNumber)55 COSBase (com.tom_roush.pdfbox.cos.COSBase)29 MissingOperandException (com.tom_roush.pdfbox.contentstream.operator.MissingOperandException)18 COSArray (com.tom_roush.pdfbox.cos.COSArray)17 COSInteger (com.tom_roush.pdfbox.cos.COSInteger)10 PointF (android.graphics.PointF)6 IOException (java.io.IOException)6 COSName (com.tom_roush.pdfbox.cos.COSName)5 PDBorderStyleDictionary (com.tom_roush.pdfbox.pdmodel.interactive.annotation.PDBorderStyleDictionary)5 COSObject (com.tom_roush.pdfbox.cos.COSObject)4 PDAnnotationMarkup (com.tom_roush.pdfbox.pdmodel.interactive.annotation.PDAnnotationMarkup)4 COSFloat (com.tom_roush.pdfbox.cos.COSFloat)3 PDFont (com.tom_roush.pdfbox.pdmodel.font.PDFont)3 ArrayList (java.util.ArrayList)3 Operator (com.tom_roush.pdfbox.contentstream.operator.Operator)2 COSDictionary (com.tom_roush.pdfbox.cos.COSDictionary)2 COSObjectKey (com.tom_roush.pdfbox.cos.COSObjectKey)2 COSStream (com.tom_roush.pdfbox.cos.COSStream)2 PDFStreamParser (com.tom_roush.pdfbox.pdfparser.PDFStreamParser)2 PDRectangle (com.tom_roush.pdfbox.pdmodel.common.PDRectangle)2