Author: msahyoun
Date: Sat Apr 14 13:48:09 2018
New Revision: 1829139

URL: http://svn.apache.org/viewvc?rev=1829139&view=rev
Log:
PDFBOX-3809: return early for empty field list; remove rendering test for 
flatten of specific fields

Modified:
    
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroForm.java
    
pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroFormTest.java

Modified: 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroForm.java
URL: 
http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroForm.java?rev=1829139&r1=1829138&r2=1829139&view=diff
==============================================================================
--- 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroForm.java
 (original)
+++ 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroForm.java
 Sat Apr 14 13:48:09 2018
@@ -250,6 +250,11 @@ public final class PDAcroForm implements
      */
     public void flatten(List<PDField> fields, boolean refreshAppearances) 
throws IOException
     {
+        // Nothing to flatten if there are no fields provided
+        if (fields.isEmpty()) {
+            return;
+        }
+        
         // for dynamic XFA forms there is no flatten as this would mean to do 
a rendering
         // from the XFA content into a static PDF.
         if (xfaIsDynamic())
@@ -282,7 +287,7 @@ public final class PDAcroForm implements
             List<PDAnnotation> annotations = new ArrayList<>();
                        
             for (PDAnnotation annotation: page.getAnnotations())
-            {   
+            {                
                 if (widgetsForPageMap != null && 
widgetsForPageMap.get(annotation.getCOSObject()) == null)
                 {
                     annotations.add(annotation);                 

Modified: 
pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroFormTest.java
URL: 
http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroFormTest.java?rev=1829139&r1=1829138&r2=1829139&view=diff
==============================================================================
--- 
pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroFormTest.java
 (original)
+++ 
pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroFormTest.java
 Sat Apr 14 13:48:09 2018
@@ -150,8 +150,7 @@ public class PDAcroFormTest
         File file = new File(OUT_DIR, 
"AlignmentTests-flattened-specificFields.pdf");
         
         List<PDField> fieldsToFlatten = new ArrayList<>();
-        
-        
+                
         try (PDDocument testPdf = PDDocument.load(new File(IN_DIR, 
"AlignmentTests.pdf")))
         {
             PDAcroForm acroFormToFlatten = 
testPdf.getDocumentCatalog().getAcroForm();
@@ -172,14 +171,6 @@ public class PDAcroFormTest
             
             testPdf.save(file);
         }
-        // compare rendering
-        TestPDFToImage testPDFToImage = new 
TestPDFToImage(TestPDFToImage.class.getName());
-        if (!testPDFToImage.doTestFile(file, IN_DIR.getAbsolutePath(), 
OUT_DIR.getAbsolutePath()))
-        {
-            // don't fail, rendering is different on different systems, result 
must be viewed manually
-            System.out.println("Rendering of " + file + " failed or is not 
identical to expected rendering in " + IN_DIR + " directory");
-        }
-        
     }    
     
     /*


Reply via email to