Class PdfGraphicExporter

java.lang.Object
uk.ac.starlink.ttools.plot.GraphicExporter
uk.ac.starlink.ttools.plot.PdfGraphicExporter

public abstract class PdfGraphicExporter extends GraphicExporter
GraphicExporter implementation that exports to PDF format. The best way to turn fonts are turned into graphics in PDFs is not obvious, so this class parameterises the options. Static members provide ways of getting useful instances.
Since:
12 Feb 2013
Author:
Mark Taylor
  • Field Details

    • BASIC

      public static PdfGraphicExporter BASIC
      Exporter which uses the default font mapper. OK for standard fonts.
    • GLYPH_TEXT

      public static PdfGraphicExporter GLYPH_TEXT
      Exporter which writes text as shapes not using fonts. Will generate reasonable output for any font without additional preparation. However, the output shapes are not perfect (visible only at huge magnification) and it may be less efficient if there's a lot of text (though possibly more efficient if there's very little).
  • Constructor Details

    • PdfGraphicExporter

      protected PdfGraphicExporter()
      Constructor.
  • Method Details

    • createExternalFontExporter

      public static PdfGraphicExporter createExternalFontExporter(URL fontsUrl)
      Returns an exporter which uses externally stored fonts. Output is perfect. A location must be provided for a resource giving a list of font locations. If the fonts can't be found, behaviour reverts to that of GLYPH_TEXT.
      Parameters:
      fontsUrl - location of a text file of font resource strings (typically file names or URLs of .ttf files)
      Returns:
      new exporter using external fonts
    • exportGraphic

      public void exportGraphic(Picture picture, OutputStream out) throws IOException
      Description copied from class: GraphicExporter
      Paints the given picture to an output stream using some graphics format or other. This method should not close the stream.
      Specified by:
      exportGraphic in class GraphicExporter
      Parameters:
      picture - picture to draw
      out - destination output stream
      Throws:
      IOException
    • createGraphics

      public abstract Graphics2D createGraphics(com.lowagie.text.pdf.PdfContentByte pcb, int width, int height)
      Returns a graphics context which can be used to write to a given PDF content object. There is not a single obvious implementation of this method; the best way to do it depends on how text glyphs are to be rendered.
      Parameters:
      pcb - PDF content object
      width - in pixels
      height - in pixels
      Returns:
      new graphics context