pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1777380 - /pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java
Date Wed, 04 Jan 2017 21:42:20 GMT
Author: tilman
Date: Wed Jan  4 21:42:20 2017
New Revision: 1777380

URL: http://svn.apache.org/viewvc?rev=1777380&view=rev
Log:
PDFBOX-3000: adjust pagesize and bounds for non (0,0) origin

Modified:
    pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java

Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java?rev=1777380&r1=1777379&r2=1777380&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java (original)
+++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java Wed
Jan  4 21:42:20 2017
@@ -1255,7 +1255,8 @@ public class PageDrawer extends PDFGraph
             AffineTransform xformOriginal = xform;
             xform = AffineTransform.getScaleInstance(m.getScalingFactorX(), m.getScalingFactorY());
             PDRectangle pageSizeOriginal = pageSize;
-            pageSize = new PDRectangle(0, 0,
+            pageSize = new PDRectangle(minX / Math.abs(m.getScalingFactorX()), 
+                                       minY / Math.abs(m.getScalingFactorY()),
                         (float) bounds.getWidth() / Math.abs(m.getScalingFactorX()),
                         (float) bounds.getHeight() / Math.abs(m.getScalingFactorY()));
             int pageRotationOriginal = pageRotation;
@@ -1314,7 +1315,9 @@ public class PageDrawer extends PDFGraph
             AffineTransform dpiTransform = AffineTransform.getScaleInstance(Math.abs(m.getScalingFactorX()),
Math.abs(m.getScalingFactorY()));
             size = dpiTransform.transform(size, size);
             // Flip y
-            return new Rectangle2D.Double(minX, size.getY() - minY - height, width, height);
+            return new Rectangle2D.Double(minX - pageSize.getLowerLeftX() * m.getScalingFactorX(),
+                    size.getY() - minY - height + pageSize.getLowerLeftY() * m.getScalingFactorY(),
+                    width, height);
         }
     }
 }



Mime
View raw message