pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From msahy...@apache.org
Subject svn commit: r1780893 - /pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/multipdf/MergeAcroFormsTest.java
Date Mon, 30 Jan 2017 10:42:13 GMT
Author: msahyoun
Date: Mon Jan 30 10:42:13 2017
New Revision: 1780893

URL: http://svn.apache.org/viewvc?rev=1780893&view=rev
Log:
PDFBOX-1100: add unit test to ensure /AP and /V entry

Modified:
    pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/multipdf/MergeAcroFormsTest.java

Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/multipdf/MergeAcroFormsTest.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/multipdf/MergeAcroFormsTest.java?rev=1780893&r1=1780892&r2=1780893&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/multipdf/MergeAcroFormsTest.java (original)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/multipdf/MergeAcroFormsTest.java Mon
Jan 30 10:42:13 2017
@@ -26,6 +26,8 @@ import java.net.URL;
 
 import org.apache.pdfbox.cos.COSName;
 import org.apache.pdfbox.pdmodel.PDDocument;
+import org.apache.pdfbox.pdmodel.interactive.form.PDAcroForm;
+import org.apache.pdfbox.pdmodel.interactive.form.PDField;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -75,5 +77,45 @@ public class MergeAcroFormsTest
         assertEquals("There shall be 1 annotation for the second page", 1, mergedPDF.getPage(0).getAnnotations().size());
 
         mergedPDF.close();
+    }    
+    
+    /*
+     * PDFBOX-1100 Ensure that after merging the PDFs there is an AP and V entry.
+     */
+    @Test
+    public void testAPEntry() throws IOException {
+        
+        // Merge the PDFs form PDFBOX-1100
+        PDFMergerUtility merger = new PDFMergerUtility();
+        
+        URL url1 = new URL("https://issues.apache.org/jira/secure/attachment/12490774/a.pdf");
+        InputStream is1 = url1.openStream();
+
+        URL url2 = new URL("https://issues.apache.org/jira/secure/attachment/12490775/b.pdf");
+        InputStream is2 = url2.openStream();
+        File pdfOutput = new File(OUT_DIR,"PDFBOX-1100.pdf");
+        merger.setDestinationFileName(pdfOutput.getAbsolutePath());
+        merger.addSource(is1);
+        merger.addSource(is2);
+        merger.mergeDocuments(null);
+        
+        // Test merge result
+        PDDocument mergedPDF = PDDocument.load(pdfOutput);
+        assertEquals("There shall be 2 pages", 2, mergedPDF.getNumberOfPages());
+        
+        PDAcroForm acroForm = mergedPDF.getDocumentCatalog().getAcroForm();
+        
+        PDField formField = acroForm.getField("Testfeld");
+        assertNotNull("There shall be an /AP entry for the field", formField.getCOSObject().getDictionaryObject(COSName.AP));
+        assertNotNull("There shall be a /V entry for the field", formField.getCOSObject().getDictionaryObject(COSName.V));
+
+        formField = acroForm.getField("Testfeld2");
+        assertNotNull("There shall be an /AP entry for the field", formField.getCOSObject().getDictionaryObject(COSName.AP));
+        assertNotNull("There shall be a /V entry for the field", formField.getCOSObject().getDictionaryObject(COSName.V));
+
+        mergedPDF.close();
     }
+    
+    
+    
 }



Mime
View raw message