From 5b75bee76bcd92c0a9af32ca24b4f42db55686cf Mon Sep 17 00:00:00 2001 From: Jeremias Maerki Date: Mon, 26 Apr 2010 11:26:08 +0000 Subject: [PATCH] Added a save/restoreGraphicsState pair for the initial coordinate system in PDF output for easier post-processing. The missing q/Q pair caused content to be upside-down when simply a new content stream is appended to the page. With this change the initial coordinate system is restored after FOP's stream is finished. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@938005 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/fop/render/pdf/PDFDocumentHandler.java | 4 +++- src/java/org/apache/fop/render/pdf/PDFRenderer.java | 6 ++---- src/java/org/apache/fop/util/AbstractPaintingState.java | 3 +++ status.xml | 4 ++++ 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/java/org/apache/fop/render/pdf/PDFDocumentHandler.java b/src/java/org/apache/fop/render/pdf/PDFDocumentHandler.java index 6025fb486..bc2f16f45 100644 --- a/src/java/org/apache/fop/render/pdf/PDFDocumentHandler.java +++ b/src/java/org/apache/fop/render/pdf/PDFDocumentHandler.java @@ -245,6 +245,7 @@ public class PDFDocumentHandler extends AbstractBinaryWritingIFDocumentHandler { AffineTransform basicPageTransform = new AffineTransform(1, 0, 0, -1, 0, (scaleY * size.height) / 1000f); basicPageTransform.scale(scaleX, scaleY); + generator.saveGraphicsState(); generator.concatenate(basicPageTransform); } @@ -259,7 +260,8 @@ public class PDFDocumentHandler extends AbstractBinaryWritingIFDocumentHandler { /** {@inheritDoc} */ public void endPageContent() throws IFException { - //nop + generator.restoreGraphicsState(); + //for top-level transform to change the default coordinate system } /** {@inheritDoc} */ diff --git a/src/java/org/apache/fop/render/pdf/PDFRenderer.java b/src/java/org/apache/fop/render/pdf/PDFRenderer.java index c280ac6fb..aab84807c 100644 --- a/src/java/org/apache/fop/render/pdf/PDFRenderer.java +++ b/src/java/org/apache/fop/render/pdf/PDFRenderer.java @@ -495,16 +495,14 @@ public class PDFRenderer extends AbstractPathOrientedRenderer implements PDFConf this.borderPainter = new PDFBorderPainter(this.generator); // Transform the PDF's default coordinate system (0,0 at lower left) to the PDFRenderer's + saveGraphicsState(); AffineTransform basicPageTransform = new AffineTransform(1, 0, 0, -1, 0, pageHeight / 1000f); generator.concatenate(basicPageTransform); - /* - currentState.concatenate(basicPageTransform); - currentStream.add(CTMHelper.toPDFString(basicPageTransform, false) + " cm\n"); - */ super.renderPage(page); + restoreGraphicsState(); if (accessEnabled) { logicalStructureHandler.endPage(); } diff --git a/src/java/org/apache/fop/util/AbstractPaintingState.java b/src/java/org/apache/fop/util/AbstractPaintingState.java index 4fb6b173c..c0c3c7fc8 100644 --- a/src/java/org/apache/fop/util/AbstractPaintingState.java +++ b/src/java/org/apache/fop/util/AbstractPaintingState.java @@ -513,6 +513,9 @@ public abstract class AbstractPaintingState implements Cloneable, Serializable { data.fontSize = this.fontSize; data.lineWidth = this.lineWidth; data.dashArray = this.dashArray; + if (this.transform == null) { + this.transform = new AffineTransform(); + } data.transform = new AffineTransform(this.transform); return data; } diff --git a/status.xml b/status.xml index 3925cac48..bac90b3ea 100644 --- a/status.xml +++ b/status.xml @@ -58,6 +58,10 @@ documents. Example: the fix of marks layering will be such a case when it's done. --> + + Added a save/restoreGraphicsState pair for the initial coordinate system in PDF output + for easier post-processing. + Added customization ability for the image loading framework from FOP's configuration file. -- 2.39.5