Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.0.16
-
None
Description
I get this when attempting to flatten the attached file (which is an "improved" version of the file from the linked issue)
26.08.2019 18:41:00.354 WARN [main] org.apache.pdfbox.pdmodel.interactive.form.PDAcroForm:853 - There has been a widget with a missing page reference. Please report to the PDFBox project
The intention is to "preserve all non widget annotations". This code reproduces the problem:
PDDocument doc = PDDocument.load(new File("PDFBOX-4636.pdf")); List<PDAnnotation> annotations = doc.getPage(0).getAnnotations(); PDColor red = new PDColor(new float[] { 1, 0, 0 }, PDDeviceRGB.INSTANCE); PDColor blue = new PDColor(new float[] { 0, 0, 1 }, PDDeviceRGB.INSTANCE); PDAnnotationCircle circleAnnotation = new PDAnnotationCircle(); circleAnnotation.setContents("Circle Annotation"); circleAnnotation.setInteriorColor(red); circleAnnotation.setColor(blue); circleAnnotation.setRectangle(new PDRectangle(100, 700, 100, 50)); circleAnnotation.setPage(doc.getPage(0)); circleAnnotation.constructAppearances(); annotations.add(circleAnnotation); doc.save("PDFBOX-4636-annotated.pdf"); doc.getDocumentCatalog().getAcroForm().flatten(); doc.save("PDFBOX-4636-flattened-bad.pdf"); doc.close(); doc = PDDocument.load(new File("PDFBOX-4636-annotatedAP.pdf")); // PDFBOX-4636-annotated.pdf opened with Adobe and saved doc.getDocumentCatalog().getAcroForm().flatten(); doc.save("PDFBOX-4636-flattened-good.pdf"); doc.close();
what should have happened: result file PDFBOX-4636-flattened-good.pdf has 1 annotation.
what happened instead: result file has PDFBOX-4636-flattened-bad.pdf no annotation, because the circle annotation has been flattened as well.
Attachments
Attachments
Issue Links
- relates to
-
PDFBOX-3301 NPE in PDAcroForm.flatten if a widget doesn't contain a /P entry
- Closed