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 2016/08/22 15:18:57 UTC

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

Author: tilman
Date: Mon Aug 22 15:18:57 2016
New Revision: 1757205

URL: http://svn.apache.org/viewvc?rev=1757205&view=rev
Log:
PDFBOX-3470: set background, fix bug in border color, don't set width 1

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

Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/AppearanceGeneratorHelper.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/AppearanceGeneratorHelper.java?rev=1757205&r1=1757204&r2=1757205&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/AppearanceGeneratorHelper.java (original)
+++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/AppearanceGeneratorHelper.java Mon Aug 22 15:18:57 2016
@@ -192,14 +192,23 @@ class AppearanceGeneratorHelper
                 appearanceStream, output);
         PDAppearanceCharacteristicsDictionary appearanceCharacteristics = widget.getAppearanceCharacteristics();
         
-        // TODO: support more entries like patterns, background color etc.
+        // TODO: support more entries like patterns, etc.
         if (appearanceCharacteristics != null)
         {
+            PDColor backgroundColour = appearanceCharacteristics.getBackground();
+            if (backgroundColour != null)
+            {
+                contents.setNonStrokingColor(backgroundColour);
+                PDRectangle bbox = resolveBoundingBox(widget, appearanceStream);
+                contents.addRect(bbox.getLowerLeftX(),bbox.getLowerLeftY(),bbox.getWidth(), bbox.getHeight());
+                contents.fill();
+            }
+
             float lineWidth = 0f;
             PDColor borderColour = appearanceCharacteristics.getBorderColour();
             if (borderColour != null)
             {
-                contents.setNonStrokingColor(borderColour);
+                contents.setStrokingColor(borderColour);
                 lineWidth = 1f;
             }
             PDBorderStyleDictionary borderStyle = widget.getBorderStyle();
@@ -210,7 +219,10 @@ class AppearanceGeneratorHelper
 
             if (lineWidth > 0)
             {
-                contents.setLineWidth(lineWidth);
+                if (lineWidth != 1)
+                {
+                    contents.setLineWidth(lineWidth);
+                }
                 PDRectangle bbox = resolveBoundingBox(widget, appearanceStream);
                 PDRectangle clipRect = applyPadding(bbox, Math.max(DEFAULT_PADDING, lineWidth/2)); 
                 contents.addRect(clipRect.getLowerLeftX(),clipRect.getLowerLeftY(),clipRect.getWidth(), clipRect.getHeight());