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

PDDocument.saveIncremental () and stack exhaustion

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 3.0.0 PDFBox
    • None
    • Writing
    • None

    Description

      Merge of fdf annotations into pdf file exhausts stack

      attempting to merge an fdf file in a pdf file, using the PDDocument.saveIncremental () method, program stack is exhausted because of infinite recursion.

      looking further in the code, it seems the infinite recursion is being started from the private boolean COSIncremental.collect(COSBase base) method.

      i have attached a zip file carrying:

      • mini.pdf: a minimal pdf file to reproduce the issue
      • mini.fdf: an fdf annotation file carrying a /Text annotation and related /Popup to reproduce the issue
      • COSIncrement.java: a modified source that generate extra traces (+ possible work-around)
      • COSIncrement-fix.java: a modified source to avoid the problem
      • Sample.java: a sample program that loads pdf, copies annotations and saves incrementally.
      • sample_run.xlsx: an extract of the Sample output to compare a working vs non-working

       

      notes:

      1- I was not able to reproduce the problem using annotations created dynamically in the code.

       

      2- It is possible to avoid this issue by altering the COSIncrement.java class (COSIncrement-fix.java):

      it records objects beING collected through enter () method ensuring object is not being collected multiple times

       

      Attachments

        1. PDFBOX-20220126.zip
          24 kB
          the blue mountain
        2. PDFBOX-20220130.zip
          39 kB
          the blue mountain

        Activity

          People

            Unassigned Unassigned
            the blue mountain the blue mountain
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated: