pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1644565 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/printing/PDFPrinter.java
Date Thu, 11 Dec 2014 07:16:27 GMT
Author: tilman
Date: Thu Dec 11 07:16:26 2014
New Revision: 1644565

URL: http://svn.apache.org/r1644565
Log:
PDFBOX-2552: normalize the rotation angle for all values

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/printing/PDFPrinter.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/printing/PDFPrinter.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/printing/PDFPrinter.java?rev=1644565&r1=1644564&r2=1644565&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/printing/PDFPrinter.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/printing/PDFPrinter.java Thu Dec 11
07:16:26 2014
@@ -355,8 +355,17 @@ public class PDFPrinter
     private PDRectangle getRotatedCropBox(PDPage page)
     {
         PDRectangle cropBox = page.getCropBox();
-        int rotation = page.getRotation();
-        if (rotation == 90 || rotation == 270)
+        int rotationAngle = page.getRotation();
+        // normalize the rotation angle
+        while (rotationAngle < 0)
+        {
+            rotationAngle += 360;
+        }
+        while (rotationAngle >= 360)
+        {
+            rotationAngle -= 360;
+        }
+        if (rotationAngle == 90 || rotationAngle == 270)
         {
             return new PDRectangle(cropBox.getLowerLeftY(), cropBox.getLowerLeftX(),
                     cropBox.getHeight(), cropBox.getWidth());



Mime
View raw message