You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ms...@apache.org on 2015/02/06 18:17:46 UTC

svn commit: r1657901 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/PDFMergerUtility.java

Author: msahyoun
Date: Fri Feb  6 17:17:45 2015
New Revision: 1657901

URL: http://svn.apache.org/r1657901
Log:
PDFBOX-2045 throw IOException when trying to merge dynamic XFA form

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

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/PDFMergerUtility.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/PDFMergerUtility.java?rev=1657901&r1=1657900&r2=1657901&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/PDFMergerUtility.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/PDFMergerUtility.java Fri Feb  6 17:17:45 2015
@@ -230,12 +230,20 @@ public class PDFMergerUtility
         {
             throw new IOException("Error: source PDF is encrypted, can't append encrypted PDF documents.");
         }
+
+        PDDocumentCatalog destCatalog = destination.getDocumentCatalog();
+        PDDocumentCatalog srcCatalog = source.getDocumentCatalog();
+        
+        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();
         destInfo.getDictionary().mergeInto(srcInfo.getDictionary());
 
-        PDDocumentCatalog destCatalog = destination.getDocumentCatalog();
-        PDDocumentCatalog srcCatalog = source.getDocumentCatalog();
+
 
         // use the highest version number for the resulting pdf
         float destVersion = destination.getDocument().getVersion();
@@ -629,5 +637,16 @@ public class PDFMergerUtility
         }
         page.setAnnotations(newannots);
     }
+    
+    /**
+     * Test for dynamic XFA content.
+     * 
+     * @param acroForm the AcroForm
+     * @return true if there is a dynamic XFA form.
+     */
+    private boolean isDynamicXfa(PDAcroForm acroForm)
+    {
+        return acroForm != null && acroForm.xfaIsDynamic();
+    }
 
 }