pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1849947 - /pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/multipdf/PDFMergerUtilityTest.java
Date Sun, 30 Dec 2018 04:03:05 GMT
Author: tilman
Date: Sun Dec 30 04:03:05 2018
New Revision: 1849947

URL: http://svn.apache.org/viewvc?rev=1849947&view=rev
Log:
PDFBOX-4417: add test for multiple /StructTreeRoot dictionaries

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=1849947&r1=1849946&r2=1849947&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
Sun Dec 30 04:03:05 2018
@@ -16,15 +16,20 @@
 package org.apache.pdfbox.multipdf;
 
 import java.awt.image.BufferedImage;
+import java.io.BufferedReader;
 import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.IOException;
+import java.io.InputStreamReader;
 import java.io.OutputStream;
 import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
 
 import junit.framework.TestCase;
+import static junit.framework.TestCase.assertEquals;
 import static junit.framework.TestCase.fail;
 import org.apache.pdfbox.cos.COSArray;
 import org.apache.pdfbox.cos.COSBase;
@@ -254,6 +259,7 @@ public class PDFMergerUtilityTest extend
         checkWithNumberTree(dst);
         checkForPageOrphans(dst);
         dst.close();
+        checkStructTreeRootCount();
     }
 
 
@@ -276,6 +282,7 @@ public class PDFMergerUtilityTest extend
         checkWithNumberTree(dst);
         checkForPageOrphans(dst);
         dst.close();
+        checkStructTreeRootCount();
     }
 
     /**
@@ -310,6 +317,27 @@ public class PDFMergerUtilityTest extend
         assertEquals(singleSetSize * 2, elementCounter.set.size());
 
         dst.close();
+        
+        checkStructTreeRootCount();
+    }
+
+    // PDFBOX-4417: check for multiple /StructTreeRoot entries that was due to
+    // incorrect merging of /K entries
+    private void checkStructTreeRootCount() throws FileNotFoundException, IOException
+    {
+        File file = new File(TARGETTESTDIR, "PDFBOX-4417-054080-merged.pdf");
+        int count = 0;
+        BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
+        String line;
+        while ((line = br.readLine()) != null)
+        {
+            if (line.equals("/Type /StructTreeRoot"))
+            {
+                ++count;
+            }
+        }
+        br.close();
+        assertEquals(1, count);
     }
 
     /**



Mime
View raw message