Package uk.ac.starlink.ttools.plot
Class PdfGraphicExporter
java.lang.Object
uk.ac.starlink.ttools.plot.GraphicExporter
uk.ac.starlink.ttools.plot.PdfGraphicExporter
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
FieldsModifier and TypeFieldDescriptionstatic PdfGraphicExporter
Exporter which uses the default font mapper.static PdfGraphicExporter
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 -
Method Summary
Modifier and TypeMethodDescriptionstatic PdfGraphicExporter
createExternalFontExporter
(URL fontsUrl) Returns an exporter which uses externally stored fonts.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.void
exportGraphic
(Picture picture, 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 Details
-
BASIC
Exporter which uses the default font mapper. OK for standard fonts. -
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
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
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:
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 objectwidth
- in pixelsheight
- in pixels- Returns:
- new graphics context
-