Author: tilman
Date: Sat May 17 11:23:33 2025
New Revision: 1925621

URL: http://svn.apache.org/viewvc?rev=1925621&view=rev
Log:
PDFBOX-6009: add test

Modified:
    
pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/multipdf/PDFMergerUtilityTest.java

Modified: 
pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/multipdf/PDFMergerUtilityTest.java
URL: 
http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/multipdf/PDFMergerUtilityTest.java?rev=1925621&r1=1925620&r2=1925621&view=diff
==============================================================================
--- 
pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/multipdf/PDFMergerUtilityTest.java
 (original)
+++ 
pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/multipdf/PDFMergerUtilityTest.java
 Sat May 17 11:23:33 2025
@@ -1404,6 +1404,32 @@ class PDFMergerUtilityTest
     }
 
     /**
+     * PDFBOX-6009: This test verifies that the destination PDF has a /K tree. 
Before the change,
+     * nodes with the "wrong" /Pg entries were deleted entirely and because 
this file has a /Pg
+     * entry with page 1 at the top, the entire /K tree would be missing.
+     *
+     * @throws IOException 
+     */
+    @Test
+    void testSplitWithPgEntryAtTheTop() throws IOException
+    {
+        try (PDDocument doc = Loader.loadPDF(new File(TARGETPDFDIR, 
"PDFBOX-6009.pdf")))
+        {
+            Splitter splitter = new Splitter();
+            splitter.setSplitAtPage(1);
+            List<PDDocument> splitResult = splitter.split(doc);
+            assertEquals(3, splitResult.size());
+            for (PDDocument dstDoc : splitResult)
+            {
+                assertEquals(1, dstDoc.getNumberOfPages());
+                checkWithNumberTree(dstDoc);
+                checkForPageOrphans(dstDoc);
+            }
+            splitResult.stream().forEach(IOUtils::closeQuietly);
+        }
+    }
+
+    /**
      * PDFBOX-5939: merge a file with an outline that has itself as a parent 
without producing a
      * stack overflow.
      *


Reply via email to