Details
-
Bug
-
Status: Closed
-
Critical
-
Resolution: Fixed
-
2.0.8
-
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
Attachments
Issue Links
- is broken by
-
PDFBOX-4004 Elements in the structure tree are not removed or corrected when flattening
- Closed
- links to