Search in sources :

Example 1 with MissingOperandException

use of com.tom_roush.pdfbox.contentstream.operator.MissingOperandException 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 2 with MissingOperandException

use of com.tom_roush.pdfbox.contentstream.operator.MissingOperandException 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 3 with MissingOperandException

use of com.tom_roush.pdfbox.contentstream.operator.MissingOperandException 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 4 with MissingOperandException

use of com.tom_roush.pdfbox.contentstream.operator.MissingOperandException 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 5 with MissingOperandException

use of com.tom_roush.pdfbox.contentstream.operator.MissingOperandException 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

MissingOperandException (com.tom_roush.pdfbox.contentstream.operator.MissingOperandException)23 COSNumber (com.tom_roush.pdfbox.cos.COSNumber)18 COSBase (com.tom_roush.pdfbox.cos.COSBase)11 PointF (android.graphics.PointF)6 COSName (com.tom_roush.pdfbox.cos.COSName)5 Matrix (com.tom_roush.pdfbox.util.Matrix)3 COSArray (com.tom_roush.pdfbox.cos.COSArray)2 PDXObject (com.tom_roush.pdfbox.pdmodel.graphics.PDXObject)2 PDFormXObject (com.tom_roush.pdfbox.pdmodel.graphics.form.PDFormXObject)2 PDTransparencyGroup (com.tom_roush.pdfbox.pdmodel.graphics.form.PDTransparencyGroup)2 COSFloat (com.tom_roush.pdfbox.cos.COSFloat)1 MissingResourceException (com.tom_roush.pdfbox.pdmodel.MissingResourceException)1 PDFont (com.tom_roush.pdfbox.pdmodel.font.PDFont)1 PDColor (com.tom_roush.pdfbox.pdmodel.graphics.color.PDColor)1 PDColorSpace (com.tom_roush.pdfbox.pdmodel.graphics.color.PDColorSpace)1 PDImageXObject (com.tom_roush.pdfbox.pdmodel.graphics.image.PDImageXObject)1 PDExtendedGraphicsState (com.tom_roush.pdfbox.pdmodel.graphics.state.PDExtendedGraphicsState)1 RenderingMode (com.tom_roush.pdfbox.pdmodel.graphics.state.RenderingMode)1 PDFMarkedContentExtractor (com.tom_roush.pdfbox.text.PDFMarkedContentExtractor)1 ArrayList (java.util.ArrayList)1