page. The quality of the bitmap depends on the target resolution setting
on the FOUserAgent.
</p>
+ <section id="bitmap-configuration">
+ <title>Configuration</title>
+ <p>
+ The TIFF and PNG renderer configuration currently allows the following settings:
+ </p>
+<source><![CDATA[<renderer mime="image/png">
+ <transparent-page-background>true</transparent-page-background>
+ <fonts><!-- described elsewhere --></fonts>
+</renderer>]]></source>
+ <p>
+ The default value for the "transparent-page-background" setting is "false" which
+ paints an opaque, white background for the whole image. If you set this to true,
+ no such background will be painted and you will get a transparent image if
+ an alpha channel is available in the output format.
+ </p>
+ </section>
</section>
<section id="txt">
<title>TXT</title>
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
+
+import org.apache.commons.logging.Log;
+
import org.apache.xmlgraphics.image.GraphicsUtil;
import org.apache.xmlgraphics.image.codec.tiff.TIFFEncodeParam;
import org.apache.xmlgraphics.image.codec.tiff.TIFFField;
import org.apache.xmlgraphics.image.codec.tiff.TIFFImageDecoder;
import org.apache.xmlgraphics.image.codec.tiff.TIFFImageEncoder;
import org.apache.xmlgraphics.image.rendered.FormatRed;
-import org.apache.commons.logging.Log;
+
import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.MimeConstants;
import org.apache.fop.render.java2d.Java2DRenderer;
* @see org.apache.avalon.framework.configuration.Configurable#configure(Configuration)
*/
public void configure(Configuration cfg) throws ConfigurationException {
+ super.configure(cfg);
//TODO Support output of monochrome bitmaps (fax-style)
int comp = cfg.getChild("compression").getAttributeAsInteger("value", 1);
import org.w3c.dom.Document;
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.area.CTM;
import org.apache.fop.image.FopImage;
import org.apache.fop.image.ImageFactory;
import org.apache.fop.image.XMLImage;
+import org.apache.fop.pdf.PDFAMode;
import org.apache.fop.render.AbstractPathOrientedRenderer;
import org.apache.fop.render.Graphics2DAdapter;
import org.apache.fop.render.RendererContext;
*/
public abstract class Java2DRenderer extends AbstractPathOrientedRenderer implements Printable {
+ /** Rendering Options key for the controlling the transparent page background option. */
+ public static final String JAVA2D_TRANSPARENT_PAGE_BACKGROUND = "transparent-page-background";
+
/** The scale factor for the image size, values: ]0 ; 1] */
protected double scaleFactor = 1;
/** true if qualityRendering is set */
protected boolean qualityRendering = true;
+ /** false: paints a non-transparent white background, true: for a transparent background */
+ protected boolean transparentPageBackground = false;
+
/** The current state, holds a Graphics2D and its context */
protected Java2DGraphicsState state;
public Java2DRenderer() {
}
+ /**
+ * @see org.apache.fop.render.AbstractRenderer#configure(
+ * org.apache.avalon.framework.configuration.Configuration)
+ */
+ public void configure(Configuration cfg) throws ConfigurationException {
+ super.configure(cfg);
+
+ String s = cfg.getChild(JAVA2D_TRANSPARENT_PAGE_BACKGROUND, true).getValue(null);
+ if (s != null) {
+ this.transparentPageBackground = "true".equalsIgnoreCase(s);
+ }
+ }
+
/**
* @see org.apache.fop.render.Renderer#setUserAgent(org.apache.fop.apps.FOUserAgent)
*/
public void setUserAgent(FOUserAgent foUserAgent) {
super.setUserAgent(foUserAgent);
userAgent.setRendererOverride(this); // for document regeneration
+
+ String s = (String)userAgent.getRendererOptions().get(JAVA2D_TRANSPARENT_PAGE_BACKGROUND);
+ if (s != null) {
+ this.transparentPageBackground = "true".equalsIgnoreCase(s);
+ }
}
/** @return the FOUserAgent */
graphics.setTransform(at);
// draw page frame
- graphics.setColor(Color.white);
- graphics.fillRect(0, 0, pageWidth, pageHeight);
+ if (!transparentPageBackground) {
+ graphics.setColor(Color.white);
+ graphics.fillRect(0, 0, pageWidth, pageHeight);
+ }
graphics.setColor(Color.black);
graphics.drawRect(-1, -1, pageWidth + 2, pageHeight + 2);
graphics.drawLine(pageWidth + 2, 0, pageWidth + 2, pageHeight + 2);