From 8f66c4de03295ce2885763fe6536c351b2b3d2a0 Mon Sep 17 00:00:00 2001 From: Jeremias Maerki Date: Mon, 5 May 2008 06:50:54 +0000 Subject: [PATCH] Bugzilla #43650: PCL Renderer: Improved page format selection so it doesn't interfere with duplex printing. Submitted by: Thomas Margreiter Note: I've only been able to verify that the change doesn't have any negative effects on simplex printers. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@653311 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/fop/render/pcl/PCLRenderer.java | 54 +++++++++++-------- status.xml | 12 +++-- 2 files changed, 40 insertions(+), 26 deletions(-) diff --git a/src/java/org/apache/fop/render/pcl/PCLRenderer.java b/src/java/org/apache/fop/render/pcl/PCLRenderer.java index b89fba9c1..921856b07 100644 --- a/src/java/org/apache/fop/render/pcl/PCLRenderer.java +++ b/src/java/org/apache/fop/render/pcl/PCLRenderer.java @@ -156,6 +156,11 @@ public class PCLRenderer extends PrintRenderer { */ private boolean disabledPJL = false; + /** contains the pageWith of the last printed page */ + private long pageWidth = 0; + /** contains the pageHeight of the last printed page */ + private long pageHeight = 0; + /** * Create the PCL renderer */ @@ -416,29 +421,34 @@ public class PCLRenderer extends PrintRenderer { } private void selectPageFormat(long pagewidth, long pageheight) throws IOException { - this.currentPageDefinition = PCLPageDefinition.getPageDefinition( - pagewidth, pageheight, 1000); - - if (this.currentPageDefinition == null) { - this.currentPageDefinition = PCLPageDefinition.getDefaultPageDefinition(); - PCLEventProducer eventProducer = PCLEventProducer.Provider.get( - getUserAgent().getEventBroadcaster()); - eventProducer.paperTypeUnavailable(this, pagewidth, pageheight, - this.currentPageDefinition.getName()); - } - if (log.isDebugEnabled()) { - log.debug("page size: " + currentPageDefinition.getPhysicalPageSize()); - log.debug("logical page: " + currentPageDefinition.getLogicalPageRect()); - } - if (this.currentPageDefinition.isLandscapeFormat()) { - gen.writeCommand("&l1O"); //Orientation - } else { - gen.writeCommand("&l0O"); //Orientation + //Only set the page format if it changes (otherwise duplex printing won't work) + if ((pagewidth != this.pageWidth) || (pageheight != this.pageHeight)) { + this.pageWidth = pagewidth; + this.pageHeight = pageheight; + + this.currentPageDefinition = PCLPageDefinition.getPageDefinition( + pagewidth, pageheight, 1000); + + if (this.currentPageDefinition == null) { + this.currentPageDefinition = PCLPageDefinition.getDefaultPageDefinition(); + log.warn("Paper type could not be determined. Falling back to: " + + this.currentPageDefinition.getName()); + } + if (log.isDebugEnabled()) { + log.debug("page size: " + currentPageDefinition.getPhysicalPageSize()); + log.debug("logical page: " + currentPageDefinition.getLogicalPageRect()); + } + + if (this.currentPageDefinition.isLandscapeFormat()) { + gen.writeCommand("&l1O"); //Landscape Orientation + } else { + gen.writeCommand("&l0O"); //Portrait Orientation + } + gen.selectPageSize(this.currentPageDefinition.getSelector()); + + gen.clearHorizontalMargins(); + gen.setTopMargin(0); } - gen.selectPageSize(this.currentPageDefinition.getSelector()); - - gen.clearHorizontalMargins(); - gen.setTopMargin(0); } /** Saves the current graphics state on the stack. */ diff --git a/status.xml b/status.xml index fa3ee3c44..cfde0ca21 100644 --- a/status.xml +++ b/status.xml @@ -57,11 +57,15 @@ Added SVG support for AFP (GOCA). - + + PCL Renderer: Improved page format selection so it doesn't interfere with + duplex printing. + + Fixed a regression introduced by the fix for - Bugzilla 44286. + Bugzilla 44286. - + Activated min-height/max-height and min-width/max-width properties. @@ -69,7 +73,7 @@ If the source had an associated InputStream, an UnsupportedOperationException was triggered. - + Add partial support for the "show-destination" property on fo:basic-link (PDF output only; see limitations on the compliance page) -- 2.39.5