diff options
author | Jeremias Maerki <jeremias@apache.org> | 2008-05-05 06:50:54 +0000 |
---|---|---|
committer | Jeremias Maerki <jeremias@apache.org> | 2008-05-05 06:50:54 +0000 |
commit | 8f66c4de03295ce2885763fe6536c351b2b3d2a0 (patch) | |
tree | 64fc3936e8faf738031decff22b09c95a9a67b11 /src/java/org | |
parent | 8ef418853362f511f72c6cd5c2397aa36aae3ce2 (diff) | |
download | xmlgraphics-fop-8f66c4de03295ce2885763fe6536c351b2b3d2a0.tar.gz xmlgraphics-fop-8f66c4de03295ce2885763fe6536c351b2b3d2a0.zip |
Bugzilla #43650:
PCL Renderer: Improved page format selection so it doesn't interfere with duplex printing.
Submitted by: Thomas Margreiter <tm.at.felder.at>
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
Diffstat (limited to 'src/java/org')
-rw-r--r-- | src/java/org/apache/fop/render/pcl/PCLRenderer.java | 54 |
1 files changed, 32 insertions, 22 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. */ |