pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1850110 - /pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/multipdf/PDFMergerUtility.java
Date Tue, 01 Jan 2019 16:09:28 GMT
Author: tilman
Date: Tue Jan  1 16:09:28 2019
New Revision: 1850110

URL: http://svn.apache.org/viewvc?rev=1850110&view=rev
Log:
PDFBOX-4009: create dummy structure tree if destination doesn't have any but source has

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=1850110&r1=1850109&r2=1850110&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
Tue Jan  1 16:09:28 2019
@@ -692,14 +692,21 @@ public class PDFMergerUtility
         
         mergeOutputIntents(cloner, srcCatalog, destCatalog);
 
-        // merge logical structure hierarchy if logical structure information is available
in both source pdf and
-        // destination pdf
+        // merge logical structure hierarchy
         boolean mergeStructTree = false;
         int destParentTreeNextKey = -1;
         Map<Integer, COSObjectable> srcNumberTreeAsMap = null;
         Map<Integer, COSObjectable> destNumberTreeAsMap = null;
-        PDStructureTreeRoot destStructTree = destCatalog.getStructureTreeRoot();
         PDStructureTreeRoot srcStructTree = srcCatalog.getStructureTreeRoot();
+        PDStructureTreeRoot destStructTree = destCatalog.getStructureTreeRoot();
+        if (destStructTree == null && srcStructTree != null)
+        {
+            // create a dummy structure tree in the destination, so that the source
+            // tree is cloned. (We can't just copy the tree reference due to PDFBOX-3999)
+            destStructTree = new PDStructureTreeRoot();
+            destCatalog.setStructureTreeRoot(destStructTree);
+            destStructTree.setParentTree(new PDNumberTreeNode(PDParentTreeValue.class));
+        }
         if (destStructTree != null)
         {
             PDNumberTreeNode destParentTree = destStructTree.getParentTree();



Mime
View raw message