Skip to content

Commit 7469287

Browse files
committed
PDFBOX-5939: add unit test case
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1923386 13f79535-47bb-0310-9956-ffa450edef68
1 parent 3ab202b commit 7469287

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

pdfbox/src/test/java/org/apache/pdfbox/multipdf/PDFMergerUtilityTest.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1330,4 +1330,26 @@ void testSplitWithNamedDestinations() throws IOException
13301330
assertTrue(((PDActionGoTo) link.getAction()).getDestination() instanceof PDNamedDestination);
13311331
}
13321332
}
1333+
1334+
/**
1335+
* PDFBOX-5939: merge a file with an outline that has itself as a parent without producing a
1336+
* stack overflow.
1337+
*
1338+
* @throws IOException
1339+
*/
1340+
@Test
1341+
void testOutlinesSelfParent() throws IOException
1342+
{
1343+
PDFMergerUtility pdfMergerUtility = new PDFMergerUtility();
1344+
pdfMergerUtility.addSource(new File(TARGETPDFDIR, "PDFBOX-5939-google-docs-1.pdf"));
1345+
pdfMergerUtility.addSource(new File(TARGETPDFDIR, "PDFBOX-5939-google-docs-1.pdf"));
1346+
pdfMergerUtility.setDestinationFileName(TARGETTESTDIR + "PDFBOX-5939-google-docs-result.pdf");
1347+
pdfMergerUtility.mergeDocuments(IOUtils.createMemoryOnlyStreamCache());
1348+
1349+
try (PDDocument mergedDoc = Loader
1350+
.loadPDF(new File(TARGETTESTDIR, "PDFBOX-5939-google-docs-result.pdf")))
1351+
{
1352+
assertEquals(2, mergedDoc.getNumberOfPages());
1353+
}
1354+
}
13331355
}

0 commit comments

Comments
 (0)