pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1849940 - /pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/multipdf/PDFMergerUtilityTest.java
Date Sat, 29 Dec 2018 20:18:03 GMT
Author: tilman
Date: Sat Dec 29 20:18:03 2018
New Revision: 1849940

URL: http://svn.apache.org/viewvc?rev=1849940&view=rev
Log:
PDFBOX-4417: add test self-merging file with two dictionaries in /K

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

Modified: pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/multipdf/PDFMergerUtilityTest.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/multipdf/PDFMergerUtilityTest.java?rev=1849940&r1=1849939&r2=1849940&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/multipdf/PDFMergerUtilityTest.java
(original)
+++ pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/multipdf/PDFMergerUtilityTest.java
Sat Dec 29 20:18:03 2018
@@ -279,6 +279,40 @@ public class PDFMergerUtilityTest extend
     }
 
     /**
+     * PDFBOX-4417: Same as the previous tests, but this one failed when the previous tests
+     * succeeded because the /K tree started with two dictionaries and not with an array.
+     *
+     * @throws IOException 
+     */
+    public void testStructureTreeMerge5() throws IOException
+    {
+        PDFMergerUtility pdfMergerUtility = new PDFMergerUtility();
+        PDDocument src = PDDocument.load(new File(SRCDIR, "PDFBOX-4417-054080.pdf"));
+
+        ElementCounter elementCounter = new ElementCounter();
+        elementCounter.walk(src.getDocumentCatalog().getStructureTreeRoot().getK());
+        int singleCnt = elementCounter.cnt;
+        int singleSetSize = elementCounter.set.size();
+
+        PDDocument dst = PDDocument.load(new File(SRCDIR, "PDFBOX-4417-054080.pdf"));
+        pdfMergerUtility.appendDocument(dst, src);
+        src.close();
+        dst.save(new File(TARGETTESTDIR, "PDFBOX-4417-054080-merged.pdf"));
+        dst.close();
+        dst = PDDocument.load(new File(TARGETTESTDIR, "PDFBOX-4417-054080-merged.pdf"));
+        checkWithNumberTree(dst);
+        checkForPageOrphans(dst);
+
+        // Assume that the merged tree has double element count
+        elementCounter = new ElementCounter();
+        elementCounter.walk(dst.getDocumentCatalog().getStructureTreeRoot().getK());
+        assertEquals(singleCnt * 2, elementCounter.cnt);
+        assertEquals(singleSetSize * 2, elementCounter.set.size());
+
+        dst.close();
+    }
+
+    /**
      * PDFBOX-4408: Check that StructParent values are found in the ParentTree
      *
      * @param document



Mime
View raw message