pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1722316 - /pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/util/DrawPrintTextLocations.java
Date Wed, 30 Dec 2015 11:29:55 GMT
Author: tilman
Date: Wed Dec 30 11:29:54 2015
New Revision: 1722316

URL: http://svn.apache.org/viewvc?rev=1722316&view=rev
Log:
PDFBOX-3175: adjust transform for rotated pages

Modified:
    pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/util/DrawPrintTextLocations.java

Modified: pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/util/DrawPrintTextLocations.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/util/DrawPrintTextLocations.java?rev=1722316&r1=1722315&r2=1722316&view=diff
==============================================================================
--- pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/util/DrawPrintTextLocations.java
(original)
+++ pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/util/DrawPrintTextLocations.java
Wed Dec 30 11:29:54 2015
@@ -205,9 +205,32 @@ public class DrawPrintTextLocations exte
             flip.translate(0, getCurrentPage().getBBox().getHeight());
             flip.scale(1, -1);
             s = flip.createTransformedShape(s);
-            
+
+            AffineTransform transform = g2d.getTransform();
+            int rotation = getCurrentPage().getRotation();
+            if (rotation != 0)
+            {
+                PDRectangle mediaBox = getCurrentPage().getMediaBox();
+                switch (rotation)
+                {
+                    case 90:
+                        g2d.translate(mediaBox.getHeight(), 0);
+                        break;
+                    case 270:
+                        g2d.translate(0, mediaBox.getWidth());
+                        break;
+                    case 180:
+                        g2d.translate(mediaBox.getWidth(), mediaBox.getHeight());
+                        break;
+                }
+                g2d.rotate(Math.toRadians(rotation));
+            }
             g2d.setColor(Color.blue);
             g2d.draw(s);
+            if (rotation != 0)
+            {
+                g2d.setTransform(transform);
+            }
         }
     }
 



Mime
View raw message