Class SVGRenderer

  • All Implemented Interfaces:
    java.awt.print.Printable, Constants, Renderer

    public class SVGRenderer
    extends Java2DRenderer

    This renderer generates SVG (Scalable Vector Graphics) format.

    This class actually does not render itself, instead it extends org.apache.fop.render.java2D.Java2DRenderer and uses Apache Batik's SVGGraphics2D for SVG generation.

    • Field Detail

      • log

        private static org.apache.commons.logging.Log log
        logging instance
      • MIME_TYPE

        public static final java.lang.String MIME_TYPE
        The MIME type for the SVG format
        See Also:
        Constant Field Values
      • SVG_FILE_EXTENSION

        private static final java.lang.String SVG_FILE_EXTENSION
        See Also:
        Constant Field Values
      • firstOutputStream

        private java.io.OutputStream firstOutputStream
      • document

        private org.w3c.dom.Document document
      • svgGenerator

        private org.apache.batik.svggen.SVGGraphics2D svgGenerator
    • Constructor Detail

      • SVGRenderer

        public SVGRenderer​(FOUserAgent userAgent)
        Parameters:
        userAgent - the user agent that contains configuration details. This cannot be null.
    • Method Detail

      • getMimeType

        public java.lang.String getMimeType()
        Get the MIME type of the renderer.
        Returns:
        The MIME type of the renderer, may return null if not applicable.
      • startRenderer

        public void startRenderer​(java.io.OutputStream outputStream)
                           throws java.io.IOException
        Initiates the rendering phase. This must only be called once for a rendering. If stopRenderer is called then this may be called again for a new document rendering.
        Specified by:
        startRenderer in interface Renderer
        Overrides:
        startRenderer in class Java2DRenderer
        Parameters:
        outputStream - The OutputStream to use for output
        Throws:
        java.io.IOException - If an I/O error occurs
      • renderPage

        public void renderPage​(PageViewport pageViewport)
                        throws java.io.IOException
        This method override only stores the PageViewport in a List. No actual rendering is performed here. A renderer override renderPage() to get the freshly produced PageViewport, and render them on the fly (producing the desired BufferedImages by calling getPageImage(), which lazily starts the rendering process).
        Specified by:
        renderPage in interface Renderer
        Overrides:
        renderPage in class Java2DRenderer
        Parameters:
        pageViewport - the PageViewport object supplied by the Area Tree
        Throws:
        java.io.IOException - In case of an I/O error
        See Also:
        Renderer
      • stopRenderer

        public void stopRenderer()
                          throws java.io.IOException
        Signals the end of the rendering phase. The renderer should reset to an initial state and dispose of any resources for the completed rendering.
        Specified by:
        stopRenderer in interface Renderer
        Overrides:
        stopRenderer in class Java2DRenderer
        Throws:
        java.io.IOException - If an I/O error occurs
      • writeSVGFile

        private void writeSVGFile​(int pageNumber)
                           throws java.io.IOException
        Throws:
        java.io.IOException
      • getCurrentOutputStream

        protected java.io.OutputStream getCurrentOutputStream​(int pageNumber)
                                                       throws java.io.IOException
        Returns the OutputStream corresponding to this page
        Parameters:
        pageNumber - 0-based page number
        Returns:
        the corresponding OutputStream
        Throws:
        java.io.IOException - In case of an I/O error