Class SVGRenderer

All Implemented Interfaces:
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 Details

    • log

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

      public static final String MIME_TYPE
      The MIME type for the SVG format
      See Also:
    • SVG_FILE_EXTENSION

      private static final String SVG_FILE_EXTENSION
      See Also:
    • firstOutputStream

      private OutputStream firstOutputStream
    • document

      private Document document
    • svgGenerator

      private org.apache.batik.svggen.SVGGraphics2D svgGenerator
    • multiFileUtil

      private MultiFileRenderingUtil multiFileUtil
      Helper class for generating multiple files
  • Constructor Details

    • SVGRenderer

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

    • getMimeType

      public 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(OutputStream outputStream) throws 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:
      IOException - If an I/O error occurs
    • renderPage

      public void renderPage(PageViewport pageViewport) throws 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:
      IOException - In case of an I/O error
      See Also:
    • stopRenderer

      public void stopRenderer() throws 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:
      IOException - If an I/O error occurs
    • writeSVGFile

      private void writeSVGFile(int pageNumber) throws IOException
      Throws:
      IOException
    • getCurrentOutputStream

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