Skip to content

Commit

Permalink
PDFBOX-5939: add unit test case
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1923386 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
THausherr committed Jan 26, 2025
1 parent 3ab202b commit 7469287
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1330,4 +1330,26 @@ void testSplitWithNamedDestinations() throws IOException
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());
}
}
}

0 comments on commit 7469287

Please sign in to comment.