You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2019/08/02 18:33:20 UTC

svn commit: r1864277 - /pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroForm.java

Author: tilman
Date: Fri Aug  2 18:33:20 2019
New Revision: 1864277

URL: http://svn.apache.org/viewvc?rev=1864277&view=rev
Log:
PDFBOX-4071: simplify code

Modified:
    pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroForm.java

Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroForm.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroForm.java?rev=1864277&r1=1864276&r2=1864277&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroForm.java (original)
+++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroForm.java Fri Aug  2 18:33:20 2019
@@ -292,11 +292,7 @@ public final class PDAcroForm implements
         {
             refreshAppearances(fields);
         }
-        
-        // indicates if the original content stream
-        // has been wrapped in a q...Q pair.
-        boolean isContentStreamWrapped;
-        
+
         // the content stream to write to
         PDPageContentStream contentStream;
 
@@ -307,7 +303,10 @@ public final class PDAcroForm implements
         for (PDPage page : document.getPages())
         {
             Map<COSDictionary,PDAnnotationWidget> widgetsForPageMap = pagesWidgetsMap.get(page.getCOSObject());
-            isContentStreamWrapped = false;
+
+            // indicates if the original content stream
+            // has been wrapped in a q...Q pair.
+            boolean isContentStreamWrapped = false;
             
             List<PDAnnotation> annotations = new ArrayList<PDAnnotation>();
             
@@ -319,15 +318,8 @@ public final class PDAcroForm implements
                 }
                 else if (!annotation.isInvisible() && !annotation.isHidden() && annotation.getNormalAppearanceStream() != null)
                 {
-                    if (!isContentStreamWrapped)
-                    {
-                        contentStream = new PDPageContentStream(document, page, AppendMode.APPEND, true, true);
-                        isContentStreamWrapped = true;
-                    }
-                    else
-                    {
-                        contentStream = new PDPageContentStream(document, page, AppendMode.APPEND, true);
-                    }
+                    contentStream = new PDPageContentStream(document, page, AppendMode.APPEND, true, !isContentStreamWrapped);
+                    isContentStreamWrapped = true;
                     
                     PDAppearanceStream appearanceStream = annotation.getNormalAppearanceStream();