Search in sources :

Example 6 with COSNumber

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

the class SetLineWidth method process.

@Override
public void process(Operator operator, List<COSBase> arguments) throws IOException {
    if (arguments.isEmpty()) {
        throw new MissingOperandException(operator, arguments);
    }
    COSNumber width = (COSNumber) arguments.get(0);
    context.getGraphicsState().setLineWidth(width.floatValue());
}
Also used : MissingOperandException(com.tom_roush.pdfbox.contentstream.operator.MissingOperandException) COSNumber(com.tom_roush.pdfbox.cos.COSNumber)

Example 7 with COSNumber

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

the class SetMatrix method process.

@Override
public void process(Operator operator, List<COSBase> arguments) throws MissingOperandException {
    if (arguments.size() < 6) {
        throw new MissingOperandException(operator, arguments);
    }
    if (!checkArrayTypesClass(arguments, COSNumber.class)) {
        return;
    }
    COSNumber a = (COSNumber) arguments.get(0);
    COSNumber b = (COSNumber) arguments.get(1);
    COSNumber c = (COSNumber) arguments.get(2);
    COSNumber d = (COSNumber) arguments.get(3);
    COSNumber e = (COSNumber) arguments.get(4);
    COSNumber f = (COSNumber) arguments.get(5);
    Matrix matrix = new Matrix(a.floatValue(), b.floatValue(), c.floatValue(), d.floatValue(), e.floatValue(), f.floatValue());
    context.setTextMatrix(matrix);
    context.setTextLineMatrix(matrix.clone());
}
Also used : Matrix(com.tom_roush.pdfbox.util.Matrix) MissingOperandException(com.tom_roush.pdfbox.contentstream.operator.MissingOperandException) COSNumber(com.tom_roush.pdfbox.cos.COSNumber)

Example 8 with COSNumber

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

the class MoveText method process.

@Override
public void process(Operator operator, List<COSBase> arguments) throws MissingOperandException {
    if (arguments.size() < 2) {
        throw new MissingOperandException(operator, arguments);
    }
    Matrix textLineMatrix = context.getTextLineMatrix();
    if (textLineMatrix == null) {
        Log.w("PdfBox-Android", "TextLineMatrix is null, " + getName() + " operator will be ignored");
        return;
    }
    COSBase base0 = arguments.get(0);
    COSBase base1 = arguments.get(1);
    if (!(base0 instanceof COSNumber)) {
        return;
    }
    if (!(base1 instanceof COSNumber)) {
        return;
    }
    COSNumber x = (COSNumber) base0;
    COSNumber y = (COSNumber) base1;
    Matrix matrix = new Matrix(1, 0, 0, 1, x.floatValue(), y.floatValue());
    textLineMatrix.concatenate(matrix);
    context.setTextMatrix(textLineMatrix.clone());
}
Also used : Matrix(com.tom_roush.pdfbox.util.Matrix) MissingOperandException(com.tom_roush.pdfbox.contentstream.operator.MissingOperandException) COSNumber(com.tom_roush.pdfbox.cos.COSNumber) COSBase(com.tom_roush.pdfbox.cos.COSBase)

Example 9 with COSNumber

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

the class SetLineDashPattern method process.

@Override
public void process(Operator operator, List<COSBase> arguments) throws MissingOperandException {
    if (arguments.size() < 2) {
        throw new MissingOperandException(operator, arguments);
    }
    COSBase base0 = arguments.get(0);
    if (!(base0 instanceof COSArray)) {
        return;
    }
    COSBase base1 = arguments.get(1);
    if (!(base1 instanceof COSNumber)) {
        return;
    }
    COSArray dashArray = (COSArray) base0;
    int dashPhase = ((COSNumber) base1).intValue();
    boolean allZero = true;
    for (COSBase base : dashArray) {
        if (base instanceof COSNumber) {
            COSNumber num = (COSNumber) base;
            if (num.floatValue() != 0) {
                allZero = false;
                break;
            }
        } else {
            Log.w("PdfBox-Android", "dash array has non number element " + base + ", ignored");
            dashArray = new COSArray();
            break;
        }
    }
    if (dashArray.size() > 0 && allZero) {
        Log.w("PdfBox-Android", "dash lengths all zero, ignored");
        dashArray = new COSArray();
    }
    context.setLineDashPattern(dashArray, dashPhase);
}
Also used : COSArray(com.tom_roush.pdfbox.cos.COSArray) MissingOperandException(com.tom_roush.pdfbox.contentstream.operator.MissingOperandException) COSNumber(com.tom_roush.pdfbox.cos.COSNumber) COSBase(com.tom_roush.pdfbox.cos.COSBase)

Example 10 with COSNumber

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

the class SetTextHorizontalScaling method process.

@Override
public void process(Operator operator, List<COSBase> arguments) throws IOException {
    if (arguments.isEmpty()) {
        throw new MissingOperandException(operator, arguments);
    }
    COSNumber scaling = (COSNumber) arguments.get(0);
    context.getGraphicsState().getTextState().setHorizontalScaling(scaling.floatValue());
}
Also used : MissingOperandException(com.tom_roush.pdfbox.contentstream.operator.MissingOperandException) 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