/** * Gets the collection of the layers this layer membership operates with. */ public Collection<PdfLayer> getLayers() { final PdfObject layers = getPdfObject().get(PdfName.OCGs); if (layers instanceof PdfDictionary) { List<PdfLayer> list = new ArrayList<>(); list.add(new PdfLayer((PdfDictionary) ((PdfDictionary) layers).makeIndirect(getDocument()))); return list; } else if (layers instanceof PdfArray) { List<PdfLayer> layerList = new ArrayList<>(); for (int ind = 0; ind < ((PdfArray) layers).size(); ind++) { layerList.add(new PdfLayer(((PdfArray) (((PdfArray) layers).makeIndirect(getDocument()))).getAsDictionary(ind))); } return layerList; } return null; }
/** * <p> * Adds file associated with PDF document as a whole and identifies the relationship between them. * </p> * <p> * Associated files may be used in Pdf/A-3 and Pdf 2.0 documents. * The method is very similar to {@link PdfDocument#addFileAttachment(String, PdfFileSpec)}. * However, besides adding file description to Names tree, it adds file to array value of the AF key in the document catalog. * </p> * <p> * For associated files their associated file specification dictionaries shall include the AFRelationship key * </p> * * @param description the file description * @param fs file specification dictionary of associated file * @see PdfDocument#addFileAttachment(String, PdfFileSpec) */ public void addAssociatedFile(String description, PdfFileSpec fs) { if (null == ((PdfDictionary) fs.getPdfObject()).get(PdfName.AFRelationship)) { Logger logger = LoggerFactory.getLogger(PdfDocument.class); logger.error(LogMessageConstant.ASSOCIATED_FILE_SPEC_SHALL_INCLUDE_AFRELATIONSHIP); } PdfArray afArray = catalog.getPdfObject().getAsArray(PdfName.AF); if (afArray == null) { afArray = (PdfArray) new PdfArray().makeIndirect(this); catalog.put(PdfName.AF, afArray); } afArray.add(fs.getPdfObject()); addFileAttachment(description, fs); }
pageStructParentIndex = getOrCreatePageStructParentIndex(page); parentsOfPageMcrs.makeIndirect(structTreeRoot.getDocument()); parentTree.addEntry(pageStructParentIndex, parentsOfPageMcrs); res = true;
ocsp.makeIndirect(document); vri.put(PdfName.OCSP, ocsp); crl.makeIndirect(document); vri.put(PdfName.CRL, crl); cert.makeIndirect(document); vri.put(PdfName.Cert, cert); dss.put(PdfName.VRI, vrim); if (ocsps.size() > 0) { ocsps.makeIndirect(document); dss.put(PdfName.OCSPs, ocsps); crls.makeIndirect(document); dss.put(PdfName.CRLs, crls); certs.makeIndirect(document); dss.put(PdfName.Certs, certs);
ocsp.makeIndirect(document); vri.put(PdfName.OCSP, ocsp); crl.makeIndirect(document); vri.put(PdfName.CRL, crl); cert.makeIndirect(document); vri.put(PdfName.Cert, cert); dss.put(PdfName.VRI, vrim); if (ocsps.size() > 0) { ocsps.makeIndirect(document); dss.put(PdfName.OCSPs, ocsps); crls.makeIndirect(document); dss.put(PdfName.CRLs, crls); certs.makeIndirect(document); dss.put(PdfName.Certs, certs);
protected void applyDestination(PdfDocument document) { String destination = this.<String>getProperty(Property.DESTINATION); if (destination != null) { int pageNumber = occupiedArea.getPageNumber(); if (pageNumber < 1 || pageNumber > document.getNumberOfPages()) { Logger logger = LoggerFactory.getLogger(AbstractRenderer.class); String logMessageArg = "Property.DESTINATION, which specifies this element location as destination, see ElementPropertyContainer.setDestination."; logger.warn(MessageFormatUtil.format(LogMessageConstant.UNABLE_TO_APPLY_PAGE_DEPENDENT_PROP_UNKNOWN_PAGE_ON_WHICH_ELEMENT_IS_DRAWN, logMessageArg)); return; } PdfArray array = new PdfArray(); array.add(document.getPage(pageNumber).getPdfObject()); array.add(PdfName.XYZ); array.add(new PdfNumber(occupiedArea.getBBox().getX())); array.add(new PdfNumber(occupiedArea.getBBox().getY() + occupiedArea.getBBox().getHeight())); array.add(new PdfNumber(0)); document.addNamedDestination(destination, array.makeIndirect(document)); deleteProperty(Property.DESTINATION); } }
protected void applyDestination(PdfDocument document) { String destination = this.<String>getProperty(Property.DESTINATION); if (destination != null) { int pageNumber = occupiedArea.getPageNumber(); if (pageNumber < 1 || pageNumber > document.getNumberOfPages()) { Logger logger = LoggerFactory.getLogger(AbstractRenderer.class); String logMessageArg = "Property.DESTINATION, which specifies this element location as destination, see ElementPropertyContainer.setDestination."; logger.warn(MessageFormatUtil.format(LogMessageConstant.UNABLE_TO_APPLY_PAGE_DEPENDENT_PROP_UNKNOWN_PAGE_ON_WHICH_ELEMENT_IS_DRAWN, logMessageArg)); return; } PdfArray array = new PdfArray(); array.add(document.getPage(pageNumber).getPdfObject()); array.add(PdfName.XYZ); array.add(new PdfNumber(occupiedArea.getBBox().getX())); array.add(new PdfNumber(occupiedArea.getBBox().getY() + occupiedArea.getBBox().getHeight())); array.add(new PdfNumber(0)); document.addNamedDestination(destination, array.makeIndirect(document)); deleteProperty(Property.DESTINATION); } }