]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Added a configuration setting to the PCL renderer that lets you disable PJL commands.
authorJeremias Maerki <jeremias@apache.org>
Fri, 5 Oct 2007 14:26:20 +0000 (14:26 +0000)
committerJeremias Maerki <jeremias@apache.org>
Fri, 5 Oct 2007 14:26:20 +0000 (14:26 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@582287 13f79535-47bb-0310-9956-ffa450edef68

src/documentation/content/xdocs/trunk/output.xml
src/java/org/apache/fop/render/pcl/PCLRenderer.java
src/java/org/apache/fop/render/pcl/PCLRendererConfigurator.java
status.xml

index 0fd85095cd0cfc5b33810bbdf1af0c172f713d90..7a2a79862c2dfa8e74be8c829c9a3f620dfb1c2c 100644 (file)
@@ -329,6 +329,7 @@ out = proc.getOutputStream();]]></source>
 <source><![CDATA[<renderer mime="application/vnd.hp-PCL">
   <rendering>quality</rendering>
   <text-rendering>bitmap</text-rendering>
+  <disable-pjl>false</disable-pjl>
 </renderer>]]></source>
       <p>
         The default value for the "rendering" setting is "speed" which causes borders 
@@ -343,6 +344,12 @@ out = proc.getOutputStream();]]></source>
         If the mix of painting methods results in unwelcome output, you can set this
         to "bitmap" which causes all text to be rendered as bitmaps.
       </p>
+      <p>
+        The default value for the "disable-pjl" setting is "false". This means that
+        the PCL renderer usually generates PJL commands before and after the document
+        in order to switch a printer into PCL language. PJL commands can be disabled
+        if you set this value to "true".
+      </p>
       <p>
         You can control the output resolution for the PCL using the "target resolution" 
         setting on the FOUserAgent. The actual value will be rounded up to the next
index 9ac5d503e73424fff3beb75d91a2e2ab1768bb11..095c3bba786930bde0b6d5238a7a6ab3ff517f5b 100644 (file)
@@ -48,11 +48,6 @@ import java.util.List;
 import java.util.Map;
 import java.util.Stack;
 
-import org.w3c.dom.Document;
-
-import org.apache.xmlgraphics.java2d.GraphicContext;
-
-// FOP
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.fop.apps.FOPException;
@@ -91,6 +86,8 @@ import org.apache.fop.render.pcl.extensions.PCLElementMapping;
 import org.apache.fop.traits.BorderProps;
 import org.apache.fop.util.QName;
 import org.apache.fop.util.UnitConv;
+import org.apache.xmlgraphics.java2d.GraphicContext;
+import org.w3c.dom.Document;
 
 /**
  * Renderer for the PCL 5 printer language. It also uses HP GL/2 for certain graphic elements.
@@ -134,6 +131,11 @@ public class PCLRenderer extends PrintRenderer {
      * the mixture of native and bitmapped text does not provide the necessary quality.
      */
     private boolean allTextAsBitmaps = false;
+
+    /**
+     * Controls whether the generation of PJL commands gets disabled. 
+     */
+    private boolean disabledPJL = false;
     
     /**
      * Create the PCL renderer
@@ -141,10 +143,31 @@ public class PCLRenderer extends PrintRenderer {
     public PCLRenderer() {
     }
 
+    /**
+     * Configures the renderer to trade speed for quality if desired. One example here is the way
+     * that borders are rendered.
+     * @param qualityBeforeSpeed true if quality is more important than speed
+     */
     public void setQualityBeforeSpeed(boolean qualityBeforeSpeed) {
         this.qualityBeforeSpeed = qualityBeforeSpeed;
     }
 
+    /**
+     * Controls whether PJL commands shall be generated by the PCL renderer.
+     * @param disable true to disable PJL commands
+     */
+    public void setPJLDisabled(boolean disable) {
+        this.disabledPJL = disable;
+    }
+    
+    /**
+     * Indicates whether PJL generation is disabled.
+     * @return true if PJL generation is disabled.
+     */
+    public boolean isPJLDisabled() {
+        return this.disabledPJL;
+    }
+    
     /**
      * {@inheritDoc}
      */
@@ -318,13 +341,15 @@ public class PCLRenderer extends PrintRenderer {
         this.out = outputStream;
         this.gen = new PCLGenerator(out, getResolution());
 
-        gen.universalEndOfLanguage();
-        gen.writeText("@PJL COMMENT Produced by " + userAgent.getProducer() + "\n");
-        if (userAgent.getTitle() != null) {
-            gen.writeText("@PJL JOB NAME = \"" + userAgent.getTitle() + "\"\n");
+        if (!isPJLDisabled()) {
+            gen.universalEndOfLanguage();
+            gen.writeText("@PJL COMMENT Produced by " + userAgent.getProducer() + "\n");
+            if (userAgent.getTitle() != null) {
+                gen.writeText("@PJL JOB NAME = \"" + userAgent.getTitle() + "\"\n");
+            }
+            gen.writeText("@PJL SET RESOLUTION = " + getResolution() + "\n");
+            gen.writeText("@PJL ENTER LANGUAGE = PCL\n");
         }
-        gen.writeText("@PJL SET RESOLUTION = " + getResolution() + "\n");
-        gen.writeText("@PJL ENTER LANGUAGE = PCL\n");
         gen.resetPrinter();
         gen.setUnitOfMeasure(getResolution());
         gen.setRasterGraphicsResolution(getResolution());
@@ -334,7 +359,9 @@ public class PCLRenderer extends PrintRenderer {
     public void stopRenderer() throws IOException {
         gen.separateJobs();
         gen.resetPrinter();
-        gen.universalEndOfLanguage();
+        if (!isPJLDisabled()) {
+            gen.universalEndOfLanguage();
+        }
     }
 
     /** {@inheritDoc} */
index e0f0023c1dbf3bb486a0d7cb8de85fda7dbc824c..1330a46ac6772803ae64c4e7b8dfdc14d88c7342 100644 (file)
@@ -48,6 +48,7 @@ public class PCLRendererConfigurator extends PrintRendererConfigurator {
         Configuration cfg = super.getRendererConfig(renderer);
         if (cfg != null) {
             PCLRenderer pclRenderer = (PCLRenderer)renderer;
+            
             String rendering = cfg.getChild("rendering").getValue(null);
             if ("quality".equalsIgnoreCase(rendering)) {
                 pclRenderer.setQualityBeforeSpeed(true);
@@ -58,6 +59,7 @@ public class PCLRendererConfigurator extends PrintRendererConfigurator {
                         "Valid values for 'rendering' are 'quality' and 'speed'. Value found: " 
                             + rendering);
             }
+            
             String textRendering = cfg.getChild("text-rendering").getValue(null);
             if ("bitmap".equalsIgnoreCase(textRendering)) {
                 pclRenderer.setAllTextAsBitmaps(true);
@@ -68,6 +70,8 @@ public class PCLRendererConfigurator extends PrintRendererConfigurator {
                         "Valid values for 'text-rendering' are 'auto' and 'bitmap'. Value found: " 
                             + textRendering);
             }
+            
+            pclRenderer.setPJLDisabled(cfg.getChild("disable-pjl").getValueAsBoolean(false));
         }
     }
 }
index f04c2b08149f039b7c263dbace67bbaddfd1854f..18eb6c61c6cf06b70730270bee561b553c023639 100644 (file)
@@ -28,6 +28,9 @@
 
   <changes>
     <release version="FOP Trunk">
+      <action context="Code" dev="JM" type="add">
+        Added a configuration setting to the PCL renderer to disable PJL commands.
+      </action>
       <action context="Code" dev="JM" type="fix" fixes-bug="43464" due-to="Bruno Feurer">
         Fix to avoid a ClassCastException in renderer configuration.
       </action>