pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1613612 - /pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/util/operator/SetLineDashPattern.java
Date Sat, 26 Jul 2014 12:19:24 GMT
Author: tilman
Date: Sat Jul 26 12:19:24 2014
New Revision: 1613612

URL: http://svn.apache.org/r1613612
Log:
PDFBOX-2243: adjust negative dash phase start value to 0

Modified:
    pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/util/operator/SetLineDashPattern.java

Modified: pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/util/operator/SetLineDashPattern.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/util/operator/SetLineDashPattern.java?rev=1613612&r1=1613611&r2=1613612&view=diff
==============================================================================
--- pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/util/operator/SetLineDashPattern.java
(original)
+++ pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/util/operator/SetLineDashPattern.java
Sat Jul 26 12:19:24 2014
@@ -25,6 +25,8 @@ import org.apache.pdfbox.pdmodel.graphic
 import org.apache.pdfbox.util.PDFOperator;
 
 import java.io.IOException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 /**
  * Implementation of content stream operator for page drawer.
@@ -36,7 +38,13 @@ public class SetLineDashPattern extends 
 {
 
     /**
+     * log instance
+     */
+    private static final Log LOG = LogFactory.getLog(SetLineDashPattern.class);
+
+    /**
      * Set the line dash pattern.
+     *
      * @param operator The operator that is being executed.
      * @param arguments List
      *
@@ -44,9 +52,14 @@ public class SetLineDashPattern extends 
      */
     public void process(PDFOperator operator, List<COSBase> arguments) throws IOException
     {
-        COSArray dashArray = (COSArray)arguments.get( 0 );
-        int dashPhase = ((COSNumber)arguments.get( 1 )).intValue();
-        PDLineDashPattern lineDash = new PDLineDashPattern( dashArray, dashPhase );
-        context.getGraphicsState().setLineDashPattern( lineDash );
+        COSArray dashArray = (COSArray) arguments.get(0);
+        int dashPhase = ((COSNumber) arguments.get(1)).intValue();
+        if (dashPhase < 0)
+        {
+            LOG.warn("dash phaseStart has negative value " + dashPhase + ", set to 0");
+            dashPhase = 0;
+        }
+        PDLineDashPattern lineDash = new PDLineDashPattern(dashArray, dashPhase);
+        context.getGraphicsState().setLineDashPattern(lineDash);
     }
 }



Mime
View raw message