Search in sources :

Example 6 with PDTransparencyGroup

use of com.tom_roush.pdfbox.pdmodel.graphics.form.PDTransparencyGroup in project PdfBox-Android by TomRoush.

the class DrawObject method process.

@Override
public void process(Operator operator, List<COSBase> operands) throws IOException {
    if (operands.isEmpty()) {
        throw new MissingOperandException(operator, operands);
    }
    COSBase base0 = operands.get(0);
    if (!(base0 instanceof COSName)) {
        return;
    }
    COSName objectName = (COSName) base0;
    PDXObject xobject = context.getResources().getXObject(objectName);
    if (xobject == null) {
        throw new MissingResourceException("Missing XObject: " + objectName.getName());
    } else if (xobject instanceof PDImageXObject) {
        PDImageXObject image = (PDImageXObject) xobject;
        context.drawImage(image);
    } else if (xobject instanceof PDFormXObject) {
        try {
            context.increaseLevel();
            if (context.getLevel() > 25) {
                Log.e("PdfBox-Android", "recursion is too deep, skipping form XObject");
                return;
            }
            PDFormXObject form = (PDFormXObject) xobject;
            if (form instanceof PDTransparencyGroup) {
                context.showTransparencyGroup((PDTransparencyGroup) form);
            } else {
                context.showForm(form);
            }
        } finally {
            context.decreaseLevel();
        }
    }
}
Also used : PDTransparencyGroup(com.tom_roush.pdfbox.pdmodel.graphics.form.PDTransparencyGroup) PDImageXObject(com.tom_roush.pdfbox.pdmodel.graphics.image.PDImageXObject) COSName(com.tom_roush.pdfbox.cos.COSName) MissingOperandException(com.tom_roush.pdfbox.contentstream.operator.MissingOperandException) MissingResourceException(com.tom_roush.pdfbox.pdmodel.MissingResourceException) COSBase(com.tom_roush.pdfbox.cos.COSBase) PDFormXObject(com.tom_roush.pdfbox.pdmodel.graphics.form.PDFormXObject) PDXObject(com.tom_roush.pdfbox.pdmodel.graphics.PDXObject)

Aggregations

PDTransparencyGroup (com.tom_roush.pdfbox.pdmodel.graphics.form.PDTransparencyGroup)6 COSName (com.tom_roush.pdfbox.cos.COSName)4 PDXObject (com.tom_roush.pdfbox.pdmodel.graphics.PDXObject)4 PDFormXObject (com.tom_roush.pdfbox.pdmodel.graphics.form.PDFormXObject)4 COSBase (com.tom_roush.pdfbox.cos.COSBase)3 MissingOperandException (com.tom_roush.pdfbox.contentstream.operator.MissingOperandException)2 PDImageXObject (com.tom_roush.pdfbox.pdmodel.graphics.image.PDImageXObject)2 IOException (java.io.IOException)2 AffineTransform (com.tom_roush.harmony.awt.geom.AffineTransform)1 COSDictionary (com.tom_roush.pdfbox.cos.COSDictionary)1 COSStream (com.tom_roush.pdfbox.cos.COSStream)1 MissingResourceException (com.tom_roush.pdfbox.pdmodel.MissingResourceException)1 PDResources (com.tom_roush.pdfbox.pdmodel.PDResources)1 ResourceCache (com.tom_roush.pdfbox.pdmodel.ResourceCache)1 PDStream (com.tom_roush.pdfbox.pdmodel.common.PDStream)1 BlendMode (com.tom_roush.pdfbox.pdmodel.graphics.blend.BlendMode)1 PDExtendedGraphicsState (com.tom_roush.pdfbox.pdmodel.graphics.state.PDExtendedGraphicsState)1 PDSoftMask (com.tom_roush.pdfbox.pdmodel.graphics.state.PDSoftMask)1 PDFMarkedContentExtractor (com.tom_roush.pdfbox.text.PDFMarkedContentExtractor)1 Matrix (com.tom_roush.pdfbox.util.Matrix)1