Author: tilman
Date: Fri May  7 04:43:22 2021
New Revision: 1889587

URL: http://svn.apache.org/viewvc?rev=1889587&view=rev
Log:
PDFBOX-4892: optimize, as suggested by valerybokov

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

Modified: 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/multipdf/PDFMergerUtility.java
URL: 
http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/multipdf/PDFMergerUtility.java?rev=1889587&r1=1889586&r2=1889587&view=diff
==============================================================================
--- 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/multipdf/PDFMergerUtility.java
 (original)
+++ 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/multipdf/PDFMergerUtility.java
 Fri May  7 04:43:22 2021
@@ -516,8 +516,8 @@ public class PDFMergerUtility
         if (isDynamicXfa(srcCatalog.getAcroForm()))
         {
             throw new IOException("Error: can't merge source document 
containing dynamic XFA form content.");
-        }   
-        
+        }
+
         PDDocumentInformation destInfo = destination.getDocumentInformation();
         PDDocumentInformation srcInfo = source.getDocumentInformation();
         mergeInto(srcInfo.getCOSObject(), destInfo.getCOSObject(), 
Collections.<COSName>emptySet());
@@ -605,10 +605,10 @@ public class PDFMergerUtility
             LOG.warn("Removed /IDTree from /Names dictionary, doesn't belong 
there");
         }
 
-        PDDocumentNameDestinationDictionary destDests = destCatalog.getDests();
         PDDocumentNameDestinationDictionary srcDests = srcCatalog.getDests();
         if (srcDests != null)
         {
+            PDDocumentNameDestinationDictionary destDests = 
destCatalog.getDests();
             if (destDests == null)
             {
                 destCatalog.getCOSObject().setItem(COSName.DESTS, 
cloner.cloneForNewDocument(srcDests));
@@ -619,10 +619,10 @@ public class PDFMergerUtility
             }
         }
 
-        PDDocumentOutline destOutline = destCatalog.getDocumentOutline();
         PDDocumentOutline srcOutline = srcCatalog.getDocumentOutline();
         if (srcOutline != null)
         {
+            PDDocumentOutline destOutline = destCatalog.getDocumentOutline();
             if (destOutline == null || destOutline.getFirstChild() == null)
             {
                 PDDocumentOutline cloned = new 
PDDocumentOutline((COSDictionary) cloner.cloneForNewDocument(srcOutline));
@@ -651,9 +651,9 @@ public class PDFMergerUtility
         }
 
         PageMode destPageMode = destCatalog.getPageMode();
-        PageMode srcPageMode = srcCatalog.getPageMode();
         if (destPageMode == null)
         {
+            PageMode srcPageMode = srcCatalog.getPageMode();
             destCatalog.setPageMode(srcPageMode);
         }
 


Reply via email to