Uploaded image for project: 'PDFBox'
  1. PDFBox
  2. PDFBOX-5714

PDFBox 3.0 regression: duplicate references in dictionary values

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.0.0 PDFBox
    • 3.0.2 PDFBox, 4.0.0
    • Writing
    • 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) 

       

       

      Attachments

        1. basic-sticky-note.fdf
          0.9 kB
          Derek Wickern
        2. w4.pdf
          184 kB
          Derek Wickern
        3. out-pdfbox3.pdf
          506 kB
          Derek Wickern
        4. out-pdfbox2.pdf
          446 kB
          Derek Wickern
        5. PdfboxAnnotationRegressionTest.java
          2 kB
          Derek Wickern

        Activity

          People

            lehmi Andreas Lehmkühler
            dwickern Derek Wickern
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: