xmlgraphics-fop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jerem...@apache.org
Subject svn commit: r884241 - /xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFDocumentHandler.java
Date Wed, 25 Nov 2009 19:56:14 GMT
Author: jeremias
Date: Wed Nov 25 19:56:14 2009
New Revision: 884241

URL: http://svn.apache.org/viewvc?rev=884241&view=rev
Log:
Bugzilla #47311:
Fixes prepress boxes. Boxes need to be transformed into PDF's default coordinate system.

Modified:
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFDocumentHandler.java

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFDocumentHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFDocumentHandler.java?rev=884241&r1=884240&r2=884241&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFDocumentHandler.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFDocumentHandler.java Wed Nov
25 19:56:14 2009
@@ -24,7 +24,6 @@
 import java.awt.geom.AffineTransform;
 import java.awt.geom.Point2D;
 import java.awt.geom.Rectangle2D;
-import java.awt.geom.Rectangle2D.Double;
 import java.io.IOException;
 import java.util.Map;
 
@@ -219,13 +218,17 @@
             scaleY = scales.getY();
         }
 
+        //PDF uses the lower left as origin, need to transform from FOP's internal coord
system
+        AffineTransform boxTransform = new AffineTransform(
+                scaleX / 1000, 0, 0, -scaleY / 1000, 0, scaleY * size.getHeight() / 1000);
+
         this.currentPage = this.pdfDoc.getFactory().makePage(
                 this.pdfResources,
                 index,
-                toPointAndScale(mediaBox, scaleX, scaleY),
-                toPointAndScale(cropBox, scaleX, scaleY),
-                toPointAndScale(bleedBox, scaleX, scaleY),
-                toPointAndScale(trimBox, scaleX, scaleY));
+                toPDFCoordSystem(mediaBox, boxTransform),
+                toPDFCoordSystem(cropBox, boxTransform),
+                toPDFCoordSystem(bleedBox, boxTransform),
+                toPDFCoordSystem(trimBox, boxTransform));
         if (accessEnabled) {
             logicalStructureHandler.startPage(currentPage);
         }
@@ -244,11 +247,8 @@
         generator.concatenate(basicPageTransform);
     }
 
-    private Double toPointAndScale(Rectangle box, double scaleX, double scaleY) {
-        return new Rectangle2D.Double(box.getX() * scaleX / 1000,
-                box.getY() * scaleY / 1000,
-                box.getWidth() * scaleX / 1000,
-                box.getHeight() * scaleY / 1000);
+    private Rectangle2D toPDFCoordSystem(Rectangle box, AffineTransform transform) {
+        return transform.createTransformedShape(box).getBounds2D();
     }
 
     /** {@inheritDoc} */



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org


Mime
View raw message