Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
3.0.0 PDFBox
-
macOS 14, Java 11
Description
basic-sticky-note.fdf contains an Acrobat "sticky note", which consists of two annotations: text (2 0 obj) and popup (3 0 obj). The annotations reference each other. The text annotation's "/Popup 3 0 R" references the popup annotation. The popup's "/Parent 2 0 R" references the text annotation.
2 0 obj <<... /Popup 3 0 R ...>> endobj 3 0 obj <<... /Parent 2 0 R ...>> endobj
The attached Java program copies those annotations onto w4.pdf, saves the file, then reads it back to verify the result.
Expected Behavior
out-pdfbox2.pdf is the output using pdfbox 2.0.30. The annotation objects are reassigned to some available ID:
38 0 obj << ... /Popup 39 0 R ... >> endobj 39 0 obj << ... /Parent 38 0 R ...>> endobj
The program outputs:
correct parent? true correct popup? true
Actual Behavior
out-pdfbox3.pdf is the output using pdfbox 3.0.0. The objects are assigned a new ID but their references are unchanged, so the /Popup and /Parent reference some other arbitrary object:
3473 0 obj << ... /Popup 3 0 R ... >> endobj 3474 0 obj << ... /Parent 2 0 R ...>> endobj
The program crashes since the dereferenced /Parent is not an annotation:
Exception in thread "main" java.lang.ClassCastException: class org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationUnknown cannot be cast to class org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationMarkup (org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationUnknown and org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationMarkup are in unnamed module of loader 'app') at org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationPopup.getParent(PDAnnotationPopup.java:99) at PdfboxAnnotationRegressionTest.main(PdfboxAnnotationRegressionTest.java:45)