aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop/render/pcl
diff options
context:
space:
mode:
Diffstat (limited to 'src/java/org/apache/fop/render/pcl')
-rw-r--r--src/java/org/apache/fop/render/pcl/PCLRenderer.java54
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. */