/** * Gets an array of <b>TrapRegion</b> objects defining the page’s trapping zones * and the associated trapping parameters, as described in Adobe Technical Note #5620, * Portable Job Ticket Format. {@link PdfName#TrapRegions} key. * * @return A {@link PdfArray} of indirect references to <b>TrapRegion</b> objects. */ public PdfArray getTrapRegions() { return getPdfObject().getAsArray(PdfName.TrapRegions); }
/** * Gets separation color names of trap network appearance, {@link PdfName#SeparationColorNames} key. * * @return an {@link PdfArray} of names identifying the colorants. */ public PdfArray getSeparationColorNames() { return getPdfObject().getAsArray(PdfName.SeparationColorNames); }
/** * Gets Form XObject's BBox, {@link PdfName#BBox} key. * * @return a {@link PdfArray}, that represents {@link Rectangle}. */ public PdfArray getBBox() { return getPdfObject().getAsArray(PdfName.BBox); }
/** * Returns files associated with XObject. * * @return associated files array. */ public PdfArray getAssociatedFiles(boolean create) { PdfArray afArray = getPdfObject().getAsArray(PdfName.AF); if (afArray == null && create) { afArray = new PdfArray(); getPdfObject().put(PdfName.AF, afArray); } return afArray; }
/** * <p> * Adds file associated with PDF XObject and identifies the relationship between them. * </p> * <p> * Associated files may be used in Pdf/A-3 and Pdf 2.0 documents. * The method adds file to array value of the AF key in the XObject dictionary. * </p> * <p> * For associated files their associated file specification dictionaries shall include the AFRelationship key * </p> * * @param fs file specification dictionary of associated file */ public void addAssociatedFile(PdfFileSpec fs) { if (null == ((PdfDictionary)fs.getPdfObject()).get(PdfName.AFRelationship)) { Logger logger = LoggerFactory.getLogger(PdfXObject.class); logger.error(LogMessageConstant.ASSOCIATED_FILE_SPEC_SHALL_INCLUDE_AFRELATIONSHIP); } PdfArray afArray = getPdfObject().getAsArray(PdfName.AF); if (afArray == null) { afArray = new PdfArray(); getPdfObject().put(PdfName.AF, afArray); } afArray.add(fs.getPdfObject()); }
/** * Adds I{@code PdfFormXObject} to the specified position with specified width preserving aspect ratio. * * @param form * @param x * @param y * @param width * @return current canvas. */ private PdfCanvas addForm(PdfFormXObject form, float x, float y, float width) { PdfArray bbox = form.getPdfObject().getAsArray(PdfName.BBox); if (bbox == null) throw new PdfException(PdfException.PdfFormXobjectHasInvalidBbox); float formWidth = Math.abs(bbox.getAsNumber(2).floatValue() - bbox.getAsNumber(0).floatValue()); float formHeight = Math.abs(bbox.getAsNumber(3).floatValue() - bbox.getAsNumber(1).floatValue()); return addForm(form, width, 0, 0, width / formWidth * formHeight, x, y); }
/** * Adds {@code PdfFormXObject} to the specified position with specified height preserving aspect ratio. * * @param form * @param x * @param y * @param height * @param dummy * @return current canvas */ private PdfCanvas addForm(PdfFormXObject form, float x, float y, float height, boolean dummy) { PdfArray bbox = form.getPdfObject().getAsArray(PdfName.BBox); if (bbox == null) throw new PdfException(PdfException.PdfFormXobjectHasInvalidBbox); float formWidth = Math.abs(bbox.getAsNumber(2).floatValue() - bbox.getAsNumber(0).floatValue()); float formHeight = Math.abs(bbox.getAsNumber(3).floatValue() - bbox.getAsNumber(1).floatValue()); return addForm(form, height / formHeight * formWidth, 0, 0, height, x, y); }
Rectangle calculateViewPort(SvgDrawContext context){ float portX = 0f; float portY = 0f; float portWidth = 0f; float portHeight = 0f; PdfStream contentStream = context.getCurrentCanvas().getContentStream(); if ( ! contentStream.containsKey(PdfName.BBox) ) { throw new SvgProcessingException(SvgLogMessageConstant.ROOT_SVG_NO_BBOX); } PdfArray bboxArray = contentStream.getAsArray(PdfName.BBox); portX = bboxArray.getAsNumber(0).floatValue(); portY = bboxArray.getAsNumber(1).floatValue(); portWidth = bboxArray.getAsNumber(2).floatValue() - portX; portHeight = bboxArray.getAsNumber(3).floatValue() - portY; return new Rectangle(portX, portY, portWidth, portHeight); }
throw new PdfAConformanceException(PdfAConformanceException.LZWDECODE_FILTER_IS_NOT_PERMITTED); if (f.equals(PdfName.Crypt)) { PdfArray decodeParams = stream.getAsArray(PdfName.DecodeParms); if (decodeParams != null && i < decodeParams.size()) { PdfDictionary decodeParam = decodeParams.getAsDictionary(i);
throw new PdfAConformanceException(PdfAConformanceException.LZWDECODE_FILTER_IS_NOT_PERMITTED); if (f.equals(PdfName.Crypt)) { PdfArray decodeParams = stream.getAsArray(PdfName.DecodeParms); if (decodeParams != null && i < decodeParams.size()) { PdfDictionary decodeParam = decodeParams.getAsDictionary(i);
PdfArray xObjMatrix = xObject.getPdfObject().getAsArray(PdfName.Matrix); Rectangle transformedRect; if (xObjMatrix != null && xObjMatrix.size() == 6) {
PdfArray xObjMatrix = xObject.getPdfObject().getAsArray(PdfName.Matrix); Rectangle transformedRect; if (xObjMatrix != null && xObjMatrix.size() == 6) {
} else { PngWriter png = new PngWriter(ms); PdfArray decode = getPdfObject().getAsArray(PdfName.Decode); if (decode != null) { if (pngBitDepth == 1) {
public void handleXObject(PdfCanvasProcessor processor, Stack<CanvasTag> canvasTagHierarchy, PdfStream xObjectStream, PdfName xObjectName) { PdfDictionary resourcesDic = xObjectStream.getAsDictionary(PdfName.Resources); PdfResources resources; if (resourcesDic == null) { resources = processor.getResources(); } else { resources = new PdfResources(resourcesDic); } // we read the content bytes up here so if it fails we don't leave the graphics state stack corrupted // this is probably not necessary (if we fail on this, probably the entire content stream processing // operation should be rejected byte[] contentBytes; contentBytes = xObjectStream.getBytes(); final PdfArray matrix = xObjectStream.getAsArray(PdfName.Matrix); new PushGraphicsStateOperator().invoke(processor, null, null); if (matrix != null) { float a = matrix.getAsNumber(0).floatValue(); float b = matrix.getAsNumber(1).floatValue(); float c = matrix.getAsNumber(2).floatValue(); float d = matrix.getAsNumber(3).floatValue(); float e = matrix.getAsNumber(4).floatValue(); float f = matrix.getAsNumber(5).floatValue(); Matrix formMatrix = new Matrix(a, b, c, d, e, f); processor.getGraphicsState().updateCtm(formMatrix); } processor.processContent(contentBytes, resources); new PopGraphicsStateOperator().invoke(processor, null, null); } }
index = (PdfArray) obj; PdfArray w = xrefStream.getAsArray(PdfName.W); long prev = -1; obj = xrefStream.get(PdfName.Prev);