Skip to content

Commit 5877928

Browse files
committed
PDFBOX-6009: add test
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1925621 13f79535-47bb-0310-9956-ffa450edef68
1 parent df6ef6b commit 5877928

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1403,6 +1403,32 @@ void testSplitWithNamedDestinations() throws IOException
14031403
}
14041404
}
14051405

1406+
/**
1407+
* PDFBOX-6009: This test verifies that the destination PDF has a /K tree. Before the change,
1408+
* nodes with the "wrong" /Pg entries were deleted entirely and because this file has a /Pg
1409+
* entry with page 1 at the top, the entire /K tree would be missing.
1410+
*
1411+
* @throws IOException
1412+
*/
1413+
@Test
1414+
void testSplitWithPgEntryAtTheTop() throws IOException
1415+
{
1416+
try (PDDocument doc = Loader.loadPDF(new File(TARGETPDFDIR, "PDFBOX-6009.pdf")))
1417+
{
1418+
Splitter splitter = new Splitter();
1419+
splitter.setSplitAtPage(1);
1420+
List<PDDocument> splitResult = splitter.split(doc);
1421+
assertEquals(3, splitResult.size());
1422+
for (PDDocument dstDoc : splitResult)
1423+
{
1424+
assertEquals(1, dstDoc.getNumberOfPages());
1425+
checkWithNumberTree(dstDoc);
1426+
checkForPageOrphans(dstDoc);
1427+
}
1428+
splitResult.stream().forEach(IOUtils::closeQuietly);
1429+
}
1430+
}
1431+
14061432
/**
14071433
* PDFBOX-5939: merge a file with an outline that has itself as a parent without producing a
14081434
* stack overflow.

0 commit comments

Comments
 (0)