Package uk.ac.starlink.ttools.plot
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 Summary
Fields Modifier and Type Field Description static PdfGraphicExporter
BASIC
Exporter which uses the default font mapper.static PdfGraphicExporter
GLYPH_TEXT
Exporter which writes text as shapes not using fonts.-
Fields inherited from class uk.ac.starlink.ttools.plot.GraphicExporter
EPS, EPS_GZIP, GIF, JPEG, PNG, PNG_TRANSPARENT, SVG
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
PdfGraphicExporter()
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static PdfGraphicExporter
createExternalFontExporter(java.net.URL fontsUrl)
Returns an exporter which uses externally stored fonts.abstract java.awt.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.void
exportGraphic(Picture picture, java.io.OutputStream out)
Paints the given picture to an output stream using some graphics format or other.-
Methods inherited from class uk.ac.starlink.ttools.plot.GraphicExporter
getContentEncoding, getDescription, getFileSuffixes, getKnownExporters, getMimeType, getName, isVector, toPicture, toString
-
-
-
-
Field Detail
-
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).
-
-
Method Detail
-
createExternalFontExporter
public static PdfGraphicExporter createExternalFontExporter(java.net.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 ofGLYPH_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, java.io.OutputStream out) throws java.io.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 classGraphicExporter
- Parameters:
picture
- picture to drawout
- destination output stream- Throws:
java.io.IOException
-
createGraphics
public abstract java.awt.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 objectwidth
- in pixelsheight
- in pixels- Returns:
- new graphics context
-
-