Search in sources :

Example 61 with COSName

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

the class DrawObject method process.

@Override
public void process(Operator operator, List<COSBase> arguments) throws IOException {
    if (arguments.isEmpty()) {
        throw new MissingOperandException(operator, arguments);
    }
    COSBase base0 = arguments.get(0);
    if (!(base0 instanceof COSName)) {
        return;
    }
    COSName name = (COSName) base0;
    PDXObject xobject = context.getResources().getXObject(name);
    ((PDFMarkedContentExtractor) context).xobject(xobject);
    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) COSName(com.tom_roush.pdfbox.cos.COSName) MissingOperandException(com.tom_roush.pdfbox.contentstream.operator.MissingOperandException) PDFMarkedContentExtractor(com.tom_roush.pdfbox.text.PDFMarkedContentExtractor) COSBase(com.tom_roush.pdfbox.cos.COSBase) PDFormXObject(com.tom_roush.pdfbox.pdmodel.graphics.form.PDFormXObject) PDXObject(com.tom_roush.pdfbox.pdmodel.graphics.PDXObject)

Example 62 with COSName

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

the class SetGraphicsStateParameters method process.

@Override
public void process(Operator operator, List<COSBase> arguments) throws IOException {
    if (arguments.isEmpty()) {
        throw new MissingOperandException(operator, arguments);
    }
    COSBase base0 = arguments.get(0);
    if (!(base0 instanceof COSName)) {
        return;
    }
    // set parameters from graphics state parameter dictionary
    COSName graphicsName = (COSName) base0;
    PDExtendedGraphicsState gs = context.getResources().getExtGState(graphicsName);
    if (gs == null) {
        Log.e("PdfBox-Android", "name for 'gs' operator not found in resources: /" + graphicsName.getName());
        return;
    }
    gs.copyIntoGraphicsState(context.getGraphicsState());
}
Also used : COSName(com.tom_roush.pdfbox.cos.COSName) MissingOperandException(com.tom_roush.pdfbox.contentstream.operator.MissingOperandException) PDExtendedGraphicsState(com.tom_roush.pdfbox.pdmodel.graphics.state.PDExtendedGraphicsState) COSBase(com.tom_roush.pdfbox.cos.COSBase)

Example 63 with COSName

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

the class SetRenderingIntent method process.

@Override
public void process(Operator operator, List<COSBase> operands) throws IOException {
    if (operands.isEmpty()) {
        throw new MissingOperandException(operator, operands);
    }
    COSBase base = operands.get(0);
    if (!(base instanceof COSName)) {
        return;
    }
    context.getGraphicsState().setRenderingIntent(RenderingIntent.fromString(((COSName) base).getName()));
}
Also used : COSName(com.tom_roush.pdfbox.cos.COSName) MissingOperandException(com.tom_roush.pdfbox.contentstream.operator.MissingOperandException) COSBase(com.tom_roush.pdfbox.cos.COSBase)

Example 64 with COSName

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

the class LayerUtility method transferDict.

private void transferDict(COSDictionary orgDict, COSDictionary targetDict, Set<String> filter, boolean inclusive) throws IOException {
    for (Map.Entry<COSName, COSBase> entry : orgDict.entrySet()) {
        COSName key = entry.getKey();
        if (inclusive && !filter.contains(key.getName())) {
            continue;
        } else if (!inclusive && filter.contains(key.getName())) {
            continue;
        }
        targetDict.setItem(key, cloner.cloneForNewDocument(entry.getValue()));
    }
}
Also used : COSName(com.tom_roush.pdfbox.cos.COSName) COSBase(com.tom_roush.pdfbox.cos.COSBase) Map(java.util.Map)

Example 65 with COSName

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

the class CryptFilter method decode.

@Override
public DecodeResult decode(InputStream encoded, OutputStream decoded, COSDictionary parameters, int index) throws IOException {
    COSName encryptionName = (COSName) parameters.getDictionaryObject(COSName.NAME);
    if (encryptionName == null || encryptionName.equals(COSName.IDENTITY)) {
        // currently the only supported implementation is the Identity crypt filter
        Filter identityFilter = new IdentityFilter();
        identityFilter.decode(encoded, decoded, parameters, index);
        return new DecodeResult(parameters);
    }
    throw new IOException("Unsupported crypt filter " + encryptionName.getName());
}
Also used : COSName(com.tom_roush.pdfbox.cos.COSName) IOException(java.io.IOException)

Aggregations

COSName (com.tom_roush.pdfbox.cos.COSName)83 COSBase (com.tom_roush.pdfbox.cos.COSBase)50 COSArray (com.tom_roush.pdfbox.cos.COSArray)27 IOException (java.io.IOException)24 COSDictionary (com.tom_roush.pdfbox.cos.COSDictionary)23 COSObject (com.tom_roush.pdfbox.cos.COSObject)11 COSString (com.tom_roush.pdfbox.cos.COSString)11 HashMap (java.util.HashMap)10 Map (java.util.Map)10 PDResources (com.tom_roush.pdfbox.pdmodel.PDResources)9 COSStream (com.tom_roush.pdfbox.cos.COSStream)7 PDFormXObject (com.tom_roush.pdfbox.pdmodel.graphics.form.PDFormXObject)7 MissingOperandException (com.tom_roush.pdfbox.contentstream.operator.MissingOperandException)5 COSInteger (com.tom_roush.pdfbox.cos.COSInteger)5 COSNumber (com.tom_roush.pdfbox.cos.COSNumber)5 PDXObject (com.tom_roush.pdfbox.pdmodel.graphics.PDXObject)5 PDRectangle (com.tom_roush.pdfbox.pdmodel.common.PDRectangle)4 PDTransparencyGroup (com.tom_roush.pdfbox.pdmodel.graphics.form.PDTransparencyGroup)4 OutputStream (java.io.OutputStream)4 Operator (com.tom_roush.pdfbox.contentstream.operator.Operator)3