Details

    • Type: Bug
    • Status: Open
    • Priority: Critical
    • Resolution: Unresolved
    • Affects Version/s: 2.0.8
    • Fix Version/s: None
    • Component/s: Utilities
    • Flags:
      Patch

      Description

      After merging two tagged documents, closing the source document causes the destination document to be closed, which prevents it from being saved. The following code demonstrates the bug with the attached flattened government PDF file. The original is available here if you need it.

      @Test
      public void testMerge() throws Exception {
          PDFMergerUtility pdfMergerUtility = new PDFMergerUtility();
          PDDocument src = PDDocument.load(new File("GovFormPreFlattened.pdf"));
          PDDocument dest = PDDocument.load(new File("GovFormPreFlattened.pdf"));
          pdfMergerUtility.appendDocument(dest, src);
          src.close(); //if we don't close the src then we don't have an error
          dest.save(File.createTempFile("MergeIssue",".PDF"));
          dest.close();
      }
      

      The issue is resolved with the attached patch.

      Also I removed the "if (mergeStructTree)" is because mergeStructTree is always true here because this code is already inside an "if (mergeStructTree)".

        Attachments

        1. GeneralForbearance.pdf
          660 kB
          Tilman Hausherr
        2. pdfbox.patch
          2 kB
          Dave Hill
        3. GovFormPreFlattened.pdf
          622 kB
          Dave Hill

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                DavesPlanet Dave Hill
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated: