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();
}
}
}
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());
}
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()));
}
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()));
}
}
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());
}
Aggregations