List of usage examples for org.apache.pdfbox.cos COSName ANNOTS
COSName ANNOTS
To view the source code for org.apache.pdfbox.cos COSName ANNOTS.
Click Source Link
From source file:org.apache.fop.render.pdf.pdfbox.PDFBoxAdapter.java
License:Apache License
private Set<COSObject> copyAnnotations(PDPage page) throws IOException { COSArray annots = (COSArray) page.getCOSObject().getDictionaryObject(COSName.ANNOTS); Set<COSObject> fields = Collections.emptySet(); if (annots != null) { fields = new TreeSet<COSObject>(new CompareFields()); for (Object annot1 : annots) { Collection<COSName> exclude = new ArrayList<COSName>(); exclude.add(COSName.P);/*from w w w.j ava 2s. c o m*/ if (annot1 instanceof COSObject) { COSObject annot = (COSObject) annot1; COSObject fieldObject = annot; COSDictionary field = (COSDictionary) fieldObject.getObject(); COSObject parent; while ((parent = (COSObject) field.getItem(COSName.PARENT)) != null) { fieldObject = parent; field = (COSDictionary) fieldObject.getObject(); } fields.add(fieldObject); if (((COSDictionary) annot.getObject()).getItem(COSName.getPDFName("StructParent")) != null) { exclude.add(COSName.PARENT); } } PDFObject clonedAnnot = (PDFObject) cloneForNewDocument(annot1, annot1, exclude); if (clonedAnnot instanceof PDFDictionary) { clonedAnnot.setParent(targetPage); updateAnnotationLink((PDFDictionary) clonedAnnot); } targetPage.addAnnotation(clonedAnnot); } } return fields; }
From source file:org.lockss.pdf.pdfbox.PdfBoxPage.java
License:Open Source License
@Override public List<PdfToken> getAnnotations() { /*/*from w w w.ja v a 2s .com*/ * IMPLEMENTATION NOTE * * Annotations are just dictionaries, but because there are many * types, the PDFBox API defines a vast hierarchy of objects to * represent them. At this time, this is way too much detail for * this API, because only one type of annotation has a foreseeable * use case (the Link type). So for now, we are only representing * annotations as the dictionaries they are by circumventing the * PDAnnotation factory call in getAnnotations() (PDFBox 1.6.0: * PDPage line 780). */ COSDictionary pageDictionary = pdPage.getCOSDictionary(); COSArray annots = (COSArray) pageDictionary.getDictionaryObject(COSName.ANNOTS); if (annots == null) { return new ArrayList<PdfToken>(); } return PdfBoxTokens.getArray(annots); }
From source file:org.lockss.pdf.pdfbox.PdfBoxPage.java
License:Open Source License
@Override public void setAnnotations(List<PdfToken> annotations) { pdPage.getCOSDictionary().setItem(COSName.ANNOTS, PdfBoxTokens.asCOSArray(annotations)); }