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 2023/07/15 03:02:08 UTC
svn commit: r1911025 - /pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/PDLineDashPattern.java
Author: tilman
Date: Sat Jul 15 03:02:08 2023
New Revision: 1911025
URL: http://svn.apache.org/viewvc?rev=1911025&view=rev
Log:
PDFBOX-5636: implement clarification from PDF 2.0 when dash phase is negative
Modified:
pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/PDLineDashPattern.java
Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/PDLineDashPattern.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/PDLineDashPattern.java?rev=1911025&r1=1911024&r2=1911025&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/PDLineDashPattern.java (original)
+++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/PDLineDashPattern.java Sat Jul 15 03:02:08 2023
@@ -52,6 +52,15 @@ public final class PDLineDashPattern imp
public PDLineDashPattern(COSArray array, int phase)
{
this.array = array.toFloatArray();
+ // PDF 2.0 specification, 8.4.3.6 Line dash pattern:
+ // "If the dash phase is negative, it shall be incremented by twice the sum of all
+ // lengths in the dash array until it is positive"
+ if (phase < 0)
+ {
+ float sum2 = 2;
+ sum2 *= 2;
+ phase += (Math.floor(-phase / sum2) + 1) * sum2;
+ }
this.phase = phase;
}