Class PDFDocument
- java.lang.Object
-
- de.erichseifert.vectorgraphics2d.SizedDocument
-
- de.erichseifert.vectorgraphics2d.pdf.PDFDocument
-
- All Implemented Interfaces:
Document
class PDFDocument extends SizedDocument
Represents aDocument
in the Portable Document Format (PDF).
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
CHARSET
private Stream
contents
private java.util.Map<PDFObject,java.lang.Long>
crossReferences
Cross-reference table ("xref").private static java.lang.String
EOL
private static java.lang.String
FOOTER
private static java.lang.String
HEADER
private java.util.Map<java.lang.Integer,PDFObject>
images
private static double
MM_IN_UNITS
Constant to convert values from millimeters to PostScript®/PDF units (1/72th inch).private java.util.List<PDFObject>
objects
private Resources
resources
private java.util.Stack<GraphicsState>
states
private static java.util.Map<java.lang.Integer,java.lang.Integer>
STROKE_ENDCAPS
Mapping of stroke endcap values from Java to PDF.private static java.util.Map<java.lang.Integer,java.lang.Integer>
STROKE_LINEJOIN
Mapping of line join values for path drawing from Java to PDF.private boolean
transformed
-
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 DefaultPDFObject
addCatalog()
private DefaultPDFObject
addDictionary(java.util.Map<java.lang.String,java.lang.Object> dict)
private DefaultPDFObject
addObject(java.awt.Image image)
private DefaultPDFObject
addObject(java.util.Map<java.lang.String,java.lang.Object> dict, Payload payload)
private DefaultPDFObject
addPage(PDFObject pageTree)
private PDFObject
addPageTree(DefaultPDFObject catalog, java.util.List<PDFObject> pages)
private void
applyStateCommands(java.util.List<Command<?>> commands)
void
close()
private GraphicsState
getCurrentState()
private int
getId(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 int
getVersion(PDFObject object)
Returns the version of the specified object.private Stream
initPage()
Initializes the document and returns aStream
representing the contents.protected static byte[]
serialize(Stream stream)
protected static byte[]
serialize(TrueTypeFont font)
private byte[]
serialize(java.lang.Object obj)
private void
setFont(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)
void
writeTo(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 aStream
representing the contents.- Returns:
Stream
to 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
-PDFObject
whose 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()
-
-