Author: tilman
Date: Sun Jan 26 18:16:30 2025
New Revision: 1923384
URL: http://svn.apache.org/viewvc?rev=1923384&view=rev
Log:
PDFBOX-5939: add unit test case
Modified:
pdfbox/branches/3.0/pdfbox/src/test/java/org/apache/pdfbox/multipdf/PDFMergerUtilityTest.java
Modified:
pdfbox/branches/3.0/pdfbox/src/test/java/org/apache/pdfbox/multipdf/PDFMergerUtilityTest.java
URL:
http://svn.apache.org/viewvc/pdfbox/branches/3.0/pdfbox/src/test/java/org/apache/pdfbox/multipdf/PDFMergerUtilityTest.java?rev=1923384&r1=1923383&r2=1923384&view=diff
==============================================================================
---
pdfbox/branches/3.0/pdfbox/src/test/java/org/apache/pdfbox/multipdf/PDFMergerUtilityTest.java
(original)
+++
pdfbox/branches/3.0/pdfbox/src/test/java/org/apache/pdfbox/multipdf/PDFMergerUtilityTest.java
Sun Jan 26 18:16:30 2025
@@ -1332,4 +1332,26 @@ class PDFMergerUtilityTest
assertTrue(((PDActionGoTo) link.getAction()).getDestination()
instanceof PDNamedDestination);
}
}
+
+ /**
+ * PDFBOX-5939: merge a file with an outline that has itself as a parent
without producing a
+ * stack overflow.
+ *
+ * @throws IOException
+ */
+ @Test
+ void testOutlinesSelfParent() throws IOException
+ {
+ PDFMergerUtility pdfMergerUtility = new PDFMergerUtility();
+ pdfMergerUtility.addSource(new File(TARGETPDFDIR,
"PDFBOX-5939-google-docs-1.pdf"));
+ pdfMergerUtility.addSource(new File(TARGETPDFDIR,
"PDFBOX-5939-google-docs-1.pdf"));
+ pdfMergerUtility.setDestinationFileName(TARGETTESTDIR +
"PDFBOX-5939-google-docs-result.pdf");
+ pdfMergerUtility.mergeDocuments(IOUtils.createMemoryOnlyStreamCache());
+
+ try (PDDocument mergedDoc = Loader
+ .loadPDF(new File(TARGETTESTDIR,
"PDFBOX-5939-google-docs-result.pdf")))
+ {
+ assertEquals(2, mergedDoc.getNumberOfPages());
+ }
+ }
}