Class PDFTranscoder

  • All Implemented Interfaces:
    org.apache.avalon.framework.configuration.Configurable, org.apache.batik.transcoder.Transcoder

    public class PDFTranscoder
    extends AbstractFOPTranscoder

    This class enables to transcode an input to a PDF document.

    Two transcoding hints (KEY_WIDTH and KEY_HEIGHT) can be used to respectively specify the image width and the image height. If only one of these keys is specified, the transcoder preserves the aspect ratio of the original image.

    The KEY_BACKGROUND_COLOR defines the background color to use for opaque image formats, or the background color that may be used for image formats that support alpha channel.

    The KEY_AOI represents the area of interest to paint in device space.

    Three additional transcoding hints that act on the SVG processor can be specified:

    KEY_LANGUAGE to set the default language to use (may be used by a <switch> SVG element for example), KEY_USER_STYLESHEET_URI to fix the URI of a user stylesheet, and KEY_PIXEL_TO_MM to specify the pixel to millimeter conversion factor.

    KEY_AUTO_FONTS to disable the auto-detection of fonts installed in the system. The PDF Transcoder cannot use AWT's font subsystem and that's why the fonts have to be configured differently. By default, font auto-detection is enabled to match the behaviour of the other transcoders, but this may be associated with a price in the form of a small performance penalty. If font auto-detection is not desired, it can be disable using this key.

    This work was authored by Keiron Liddle (keiron@aftexsw.com).

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected PDFDocumentGraphics2D graphics
      Graphics2D instance that is used to paint to
      • Fields inherited from class org.apache.batik.transcoder.SVGAbstractTranscoder

        builder, ctx, curAOI, curTxf, DEFAULT_ALLOWED_SCRIPT_TYPES, DEFAULT_DEFAULT_FONT_FAMILY, height, KEY_ALLOW_EXTERNAL_RESOURCES, KEY_ALLOWED_SCRIPT_TYPES, KEY_ALTERNATE_STYLESHEET, KEY_AOI, KEY_CONSTRAIN_SCRIPT_ORIGIN, KEY_DEFAULT_FONT_FAMILY, KEY_EXECUTE_ONLOAD, KEY_HEIGHT, KEY_LANGUAGE, KEY_MAX_HEIGHT, KEY_MAX_WIDTH, KEY_MEDIA, KEY_PIXEL_TO_MM, KEY_PIXEL_UNIT_TO_MILLIMETER, KEY_SNAPSHOT_TIME, KEY_USER_STYLESHEET_URI, KEY_WIDTH, root, userAgent, width
      • Fields inherited from class org.apache.batik.transcoder.XMLAbstractTranscoder

        KEY_DOCUMENT_ELEMENT, KEY_DOCUMENT_ELEMENT_NAMESPACE_URI, KEY_DOM_IMPLEMENTATION, KEY_XML_PARSER_CLASSNAME, KEY_XML_PARSER_VALIDATING
      • Fields inherited from class org.apache.batik.transcoder.TranscoderSupport

        handler, hints
    • Constructor Detail

      • PDFTranscoder

        public PDFTranscoder()
        Constructs a new PDFTranscoder.
    • Method Detail

      • transcode

        protected void transcode​(org.w3c.dom.Document document,
                                 java.lang.String uri,
                                 org.apache.batik.transcoder.TranscoderOutput output)
                          throws org.apache.batik.transcoder.TranscoderException
        Transcodes the specified Document as an image in the specified output.
        Overrides:
        transcode in class org.apache.batik.transcoder.SVGAbstractTranscoder
        Parameters:
        document - the document to transcode
        uri - the uri of the document or null if any
        output - the ouput where to transcode
        Throws:
        org.apache.batik.transcoder.TranscoderException - if an error occured while transcoding
      • createBridgeContext

        protected org.apache.batik.bridge.BridgeContext createBridgeContext()
        Overrides:
        createBridgeContext in class org.apache.batik.transcoder.SVGAbstractTranscoder
      • createBridgeContext

        public org.apache.batik.bridge.BridgeContext createBridgeContext​(java.lang.String version)
        Overrides:
        createBridgeContext in class org.apache.batik.transcoder.SVGAbstractTranscoder