pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1863455 - /pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/ExtractText.java
Date Sat, 20 Jul 2019 09:28:00 GMT
Author: tilman
Date: Sat Jul 20 09:28:00 2019
New Revision: 1863455

URL: http://svn.apache.org/viewvc?rev=1863455&view=rev
Log:
PDFBOX-4071: avoid duplicate code; clone matrix object to avoid modifying it

Modified:
    pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/ExtractText.java

Modified: pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/ExtractText.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/ExtractText.java?rev=1863455&r1=1863454&r2=1863455&view=diff
==============================================================================
--- pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/ExtractText.java (original)
+++ pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/ExtractText.java Sat Jul 20 09:28:00
2019
@@ -399,6 +399,14 @@ public final class ExtractText
         }
     }
 
+    static int getAngle(TextPosition text)
+    {
+        // should this become a part of TextPosition?
+        Matrix m = text.getTextMatrix().clone();
+        m.concatenate(text.getFont().getFontMatrix());
+        return (int) Math.round(Math.toDegrees(Math.atan2(m.getShearY(), m.getScaleY())));
+    }
+
     /**
      * This will print the usage requirements and exit.
      */
@@ -452,9 +460,7 @@ class AngleCollector extends PDFTextStri
     @Override
     protected void processTextPosition(TextPosition text)
     {
-        Matrix m = text.getTextMatrix();
-        m.concatenate(text.getFont().getFontMatrix());
-        int angle = (int) Math.round(Math.toDegrees(Math.atan2(m.getShearY(), m.getScaleY())));
+        int angle = ExtractText.getAngle(text);
         angle = (angle + 360) % 360;
         angles.add(angle);
     }
@@ -472,9 +478,7 @@ class FilteredTextStripper extends PDFTe
     @Override
     protected void processTextPosition(TextPosition text)
     {
-        Matrix m = text.getTextMatrix();
-        m.concatenate(text.getFont().getFontMatrix());
-        int angle = (int) Math.round(Math.toDegrees(Math.atan2(m.getShearY(), m.getScaleY())));
+        int angle = ExtractText.getAngle(text);
         if (angle == 0)
         {
             super.processTextPosition(text);



Mime
View raw message