Class PDFDocument
- java.lang.Object
-
- de.erichseifert.vectorgraphics2d.SizedDocument
-
- de.erichseifert.vectorgraphics2d.pdf.PDFDocument
-
- All Implemented Interfaces:
Document
class PDFDocument extends SizedDocument
Represents aDocumentin the Portable Document Format (PDF).
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.StringCHARSETprivate Streamcontentsprivate java.util.Map<PDFObject,java.lang.Long>crossReferencesCross-reference table ("xref").private static java.lang.StringEOLprivate static java.lang.StringFOOTERprivate static java.lang.StringHEADERprivate java.util.Map<java.lang.Integer,PDFObject>imagesprivate static doubleMM_IN_UNITSConstant to convert values from millimeters to PostScript®/PDF units (1/72th inch).private java.util.List<PDFObject>objectsprivate Resourcesresourcesprivate java.util.Stack<GraphicsState>statesprivate static java.util.Map<java.lang.Integer,java.lang.Integer>STROKE_ENDCAPSMapping of stroke endcap values from Java to PDF.private static java.util.Map<java.lang.Integer,java.lang.Integer>STROKE_LINEJOINMapping of line join values for path drawing from Java to PDF.private booleantransformed
-
Constructor Summary
Constructors Constructor Description PDFDocument(CommandSequence commands, PageSize pageSize, boolean compressed)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private DefaultPDFObjectaddCatalog()private DefaultPDFObjectaddDictionary(java.util.Map<java.lang.String,java.lang.Object> dict)private DefaultPDFObjectaddObject(java.awt.Image image)private DefaultPDFObjectaddObject(java.util.Map<java.lang.String,java.lang.Object> dict, Payload payload)private DefaultPDFObjectaddPage(PDFObject pageTree)private PDFObjectaddPageTree(DefaultPDFObject catalog, java.util.List<PDFObject> pages)private voidapplyStateCommands(java.util.List<Command<?>> commands)voidclose()private GraphicsStategetCurrentState()private intgetId(PDFObject object)private byte[]getOutput(GraphicsState state, Resources resources, boolean first)private static byte[]getOutput(PDFObject image, double x, double y, double width, double height, Resources resources)private byte[]getOutput(java.awt.Color color)private static byte[]getOutput(java.awt.geom.AffineTransform transform)private byte[]getOutput(java.awt.Shape s)private byte[]getOutput(java.awt.Stroke s)private static byte[]getOutput(java.lang.String str)private static byte[]getOutput(java.lang.String str, double x, double y)private intgetVersion(PDFObject object)Returns the version of the specified object.private StreaminitPage()Initializes the document and returns aStreamrepresenting the contents.protected static byte[]serialize(Stream stream)protected static byte[]serialize(TrueTypeFont font)private byte[]serialize(java.lang.Object obj)private voidsetFont(java.lang.String fontId, float fontSize, Stream contents)private byte[]toBytes(Command<?> command)byte[]toBytes(PDFObject object)private byte[]toBytes(Resources resources)private byte[]toBytes(Stream stream)voidwriteTo(java.io.OutputStream out)-
Methods inherited from class de.erichseifert.vectorgraphics2d.SizedDocument
getPageSize, isCompressed
-
-
-
-
Field Detail
-
CHARSET
private static final java.lang.String CHARSET
- See Also:
- Constant Field Values
-
HEADER
private static final java.lang.String HEADER
- See Also:
- Constant Field Values
-
FOOTER
private static final java.lang.String FOOTER
- See Also:
- Constant Field Values
-
EOL
private static final java.lang.String EOL
- See Also:
- Constant Field Values
-
MM_IN_UNITS
private static final double MM_IN_UNITS
Constant to convert values from millimeters to PostScript®/PDF units (1/72th inch).- See Also:
- Constant Field Values
-
STROKE_ENDCAPS
private static final java.util.Map<java.lang.Integer,java.lang.Integer> STROKE_ENDCAPS
Mapping of stroke endcap values from Java to PDF.
-
STROKE_LINEJOIN
private static final java.util.Map<java.lang.Integer,java.lang.Integer> STROKE_LINEJOIN
Mapping of line join values for path drawing from Java to PDF.
-
objects
private final java.util.List<PDFObject> objects
-
crossReferences
private final java.util.Map<PDFObject,java.lang.Long> crossReferences
Cross-reference table ("xref").
-
contents
private final Stream contents
-
resources
private Resources resources
-
images
private final java.util.Map<java.lang.Integer,PDFObject> images
-
states
private final java.util.Stack<GraphicsState> states
-
transformed
private boolean transformed
-
-
Constructor Detail
-
PDFDocument
public PDFDocument(CommandSequence commands, PageSize pageSize, boolean compressed)
-
-
Method Detail
-
getCurrentState
private GraphicsState getCurrentState()
-
initPage
private Stream initPage()
Initializes the document and returns aStreamrepresenting the contents.- Returns:
Streamto which the contents are written.
-
setFont
private void setFont(java.lang.String fontId, float fontSize, Stream contents)
-
addObject
private DefaultPDFObject addObject(java.util.Map<java.lang.String,java.lang.Object> dict, Payload payload)
-
addCatalog
private DefaultPDFObject addCatalog()
-
addPageTree
private PDFObject addPageTree(DefaultPDFObject catalog, java.util.List<PDFObject> pages)
-
addPage
private DefaultPDFObject addPage(PDFObject pageTree)
-
addDictionary
private DefaultPDFObject addDictionary(java.util.Map<java.lang.String,java.lang.Object> dict)
-
addObject
private DefaultPDFObject addObject(java.awt.Image image)
-
writeTo
public void writeTo(java.io.OutputStream out) throws java.io.IOException- Throws:
java.io.IOException
-
getId
private int getId(PDFObject object)
-
getVersion
private int getVersion(PDFObject object)
Returns the version of the specified object.- Parameters:
object-PDFObjectwhose version should be determined.- Returns:
- Version number.
-
toBytes
private byte[] toBytes(Resources resources)
-
toBytes
private byte[] toBytes(Stream stream)
-
serialize
protected static byte[] serialize(Stream stream)
-
serialize
protected static byte[] serialize(TrueTypeFont font)
-
toBytes
public byte[] toBytes(PDFObject object)
-
serialize
private byte[] serialize(java.lang.Object obj)
-
toBytes
private byte[] toBytes(Command<?> command)
-
applyStateCommands
private void applyStateCommands(java.util.List<Command<?>> commands)
-
getOutput
private byte[] getOutput(java.awt.Color color)
-
getOutput
private byte[] getOutput(java.awt.Shape s)
-
getOutput
private byte[] getOutput(GraphicsState state, Resources resources, boolean first)
-
getOutput
private byte[] getOutput(java.awt.Stroke s)
-
getOutput
private static byte[] getOutput(java.awt.geom.AffineTransform transform)
-
getOutput
private static byte[] getOutput(java.lang.String str, double x, double y)
-
getOutput
private static byte[] getOutput(java.lang.String str)
-
getOutput
private static byte[] getOutput(PDFObject image, double x, double y, double width, double height, Resources resources)
-
close
public void close()
-
-