<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
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
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;
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.
* 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
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}
*/
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());
public void stopRenderer() throws IOException {
gen.separateJobs();
gen.resetPrinter();
- gen.universalEndOfLanguage();
+ if (!isPJLDisabled()) {
+ gen.universalEndOfLanguage();
+ }
}
/** {@inheritDoc} */
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);
"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);
"Valid values for 'text-rendering' are 'auto' and 'bitmap'. Value found: "
+ textRendering);
}
+
+ pclRenderer.setPJLDisabled(cfg.getChild("disable-pjl").getValueAsBoolean(false));
}
}
}