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 2018/06/04 19:19:46 UTC

svn commit: r1832887 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDFreeTextAppearanceHandler.java

Author: tilman
Date: Mon Jun  4 19:19:46 2018
New Revision: 1832887

URL: http://svn.apache.org/viewvc?rev=1832887&view=rev
Log:
PDFBOX-3353: don't rotate non angled styles

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDFreeTextAppearanceHandler.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDFreeTextAppearanceHandler.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDFreeTextAppearanceHandler.java?rev=1832887&r1=1832886&r2=1832887&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDFreeTextAppearanceHandler.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDFreeTextAppearanceHandler.java Mon Jun  4 19:19:46 2018
@@ -124,22 +124,31 @@ public class PDFreeTextAppearanceHandler
             }
             cs.stroke();
 
-            // do a transform so that first "arm" is imagined flat, like in line handler
-            // the alternative would be to apply the transform to the LE shapes directly,
-            // which would be more work and produce code difficult to understand
-            // paint the styles here and after line(s) draw, to avoid line crossing a filled shape
+            // paint the styles here and after line(s) draw, to avoid line crossing a filled shape       
             if ("FreeTextCallout".equals(annotation.getIntent())
+                    // check only needed to avoid q cm Q if LE_NONE
                     && !LE_NONE.equals(annotation.getLineEndingStyle())
                     && pathsArray.length >= 4)
             {
-                // check only needed to avoid q cm Q if LE_NONE
                 float x2 = pathsArray[2];
                 float y2 = pathsArray[3];
                 float x1 = pathsArray[0];
                 float y1 = pathsArray[1];
-                double angle = Math.atan2(y2 - y1, x2 - x1);
                 cs.saveGraphicsState();
-                cs.transform(Matrix.getRotateInstance(angle, x1, y1));
+                if (ANGLED_STYLES.contains(annotation.getLineEndingStyle()))
+                {
+                    // do a transform so that first "arm" is imagined flat,
+                    // like in line handler.
+                    // The alternative would be to apply the transform to the 
+                    // LE shape coordinates directly, which would be more work 
+                    // and produce code difficult to understand
+                    double angle = Math.atan2(y2 - y1, x2 - x1);
+                    cs.transform(Matrix.getRotateInstance(angle, x1, y1));
+                }
+                else
+                {
+                    cs.transform(Matrix.getTranslateInstance(x1, y1));
+                }
                 drawStyle(annotation.getLineEndingStyle(), cs, 0, 0, ab.width, hasStroke, hasBackground);
                 cs.restoreGraphicsState();
             }