pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1849933 - /pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/multipdf/PDFMergerUtility.java
Date Sat, 29 Dec 2018 19:06:07 GMT
Author: tilman
Date: Sat Dec 29 19:06:07 2018
New Revision: 1849933

URL: http://svn.apache.org/viewvc?rev=1849933&view=rev
Log:
PDFBOX-4417: don't use getKArray() because it brings null for some files that have only dictionaries
at the top

Modified:
    pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/multipdf/PDFMergerUtility.java

Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/multipdf/PDFMergerUtility.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/multipdf/PDFMergerUtility.java?rev=1849933&r1=1849932&r2=1849933&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/multipdf/PDFMergerUtility.java
(original)
+++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/multipdf/PDFMergerUtility.java
Sat Dec 29 19:06:07 2018
@@ -811,22 +811,23 @@ public class PDFMergerUtility
             destStructTree.setParentTree(newParentTreeNode);
             destStructTree.setParentTreeNextKey(destParentTreeNextKey);
 
-            COSDictionary kDictLevel0 = new COSDictionary();
             COSArray newKArray = new COSArray();
-            COSArray destKArray = destStructTree.getKArray();
-            COSArray srcKArray = srcStructTree.getKArray();
-            if (destKArray != null && srcKArray != null)
+            if (srcStructTree.getK() != null)
             {
-                srcKArray = (COSArray) cloner.cloneForNewDocument(srcKArray);
-                updateParentEntry(destKArray, kDictLevel0);
-                newKArray.addAll(destKArray);
-                updateParentEntry(srcKArray, kDictLevel0);
-                newKArray.addAll(srcKArray);
+                newKArray.add(cloner.cloneForNewDocument(srcStructTree.getK()));
+            }
+            if (destStructTree.getK() != null)
+            {
+                newKArray.add(destStructTree.getK());
+            }
+            if (newKArray.size() > 0)
+            {
+                COSDictionary kDictLevel0 = new COSDictionary();
+                kDictLevel0.setItem(COSName.K, newKArray);
+                kDictLevel0.setItem(COSName.P, destStructTree);
+                kDictLevel0.setItem(COSName.S, COSName.DOCUMENT);
+                destStructTree.setK(kDictLevel0);
             }
-            kDictLevel0.setItem(COSName.K, newKArray);
-            kDictLevel0.setItem(COSName.P, destStructTree);
-            kDictLevel0.setItem(COSName.S, COSName.DOCUMENT);
-            destStructTree.setK(kDictLevel0);
 
             mergeRoleMap(srcStructTree, destStructTree);
         }



Mime
View raw message