public class PDFGraphics2D extends VectorGraphics2D
Graphics2D implementation that saves all operations to a string
in the Portable Document Format (PDF).VectorGraphics2D.FontRendering| Modifier and Type | Field and Description |
|---|---|
protected static String |
FONT_RESOURCE_PREFIX
Prefix string for PDF font resource ids.
|
protected static String |
IMAGE_RESOURCE_PREFIX
Prefix string for PDF image resource ids.
|
protected static double |
MM_IN_UNITS
Constant to convert values from millimeters to PostScript®/PDF units (1/72th inch).
|
protected static String |
TRANSPARENCY_RESOURCE_PREFIX
Prefix string for PDF transparency resource ids.
|
| Constructor and Description |
|---|
PDFGraphics2D(double x,
double y,
double width,
double height)
Constructor that initializes a new
PDFGraphics2D instance. |
| Modifier and Type | Method and Description |
|---|---|
byte[] |
getBytes()
Encodes the painted data into a sequence of bytes.
|
protected String |
getFontResource(Font font)
Returns the resource describing the specified font.
|
protected String |
getFooter()
Returns a string of the footer to end a document.
|
protected String |
getImageResource(BufferedImage bufferedImg)
Returns the resource for the specified image data.
|
protected String |
getTransparencyResource(double a)
Returns the resource for the specified transparency level.
|
protected int |
peekObjId()
Returns the next PDF object id without incrementing.
|
void |
setClip(Shape clip) |
void |
setColor(Color c) |
void |
setStroke(Stroke s) |
String |
toString() |
protected void |
writeClosingDraw(Shape s)
Utility method for writing a tag closing fragment for drawing
operations.
|
protected void |
writeClosingFill(Shape s)
Utility method for writing a tag closing fragment for filling
operations.
|
protected void |
writeDict(Object... strs)
Write a PDF dictionary from the specified collection of objects.
|
protected void |
writeHeader()
Write the header to start a new document.
|
protected void |
writeImage(Image img,
int imgWidth,
int imgHeight,
double x,
double y,
double width,
double height)
Write the specified image to the document.
|
protected int |
writeObj(Object... strs)
Write a collection of elements to the document stream as PDF object.
|
protected void |
writeShape(Shape s)
Utility method for writing an arbitrary shape to.
|
protected void |
writeString(String str,
double x,
double y)
Write a text string to the document at a specified position.
|
addRenderingHints, clearRect, clip, clipRect, copyArea, create, dispose, draw, drawArc, drawGlyphVector, drawImage, drawImage, drawImage, drawImage, drawImage, drawImage, drawImage, drawImage, drawLine, drawOval, drawPolygon, drawPolyline, drawRect, drawRenderableImage, drawRenderedImage, drawRoundRect, drawString, drawString, drawString, drawString, fill, fillArc, fillOval, fillPolygon, fillRect, fillRoundRect, getBackground, getBounds, getClip, getClipBounds, getColor, getComposite, getDeviceConfiguration, getFont, getFontMetrics, getFontRenderContext, getFontRendering, getPaint, getRasteredImageSizeMaximum, getRenderingHint, getRenderingHints, getResolution, getStroke, getTransform, hit, isDistorted, isTransformed, rotate, rotate, scale, setAffineTransform, setBackground, setClip, setComposite, setFont, setFontRendering, setPaint, setPaintMode, setRasteredImageSizeMaximum, setRenderingHint, setRenderingHints, setResolution, setTransform, setXORMode, shear, size, transform, translate, translate, write, writelndraw3DRect, fill3DRectcreate, drawBytes, drawChars, drawPolygon, fillPolygon, finalize, getClipBounds, getClipRect, getFontMetrics, hitClipprotected static final String FONT_RESOURCE_PREFIX
protected static final String IMAGE_RESOURCE_PREFIX
protected static final String TRANSPARENCY_RESOURCE_PREFIX
protected static final double MM_IN_UNITS
public PDFGraphics2D(double x,
double y,
double width,
double height)
PDFGraphics2D instance.
The document dimension must be specified as parameters.x - Left offset of document in millimeters.y - Top offset of document in millimeters.width - Width of document in millimeters.height - Height of document in millimeters.protected void writeString(String str, double x, double y)
VectorGraphics2DwriteString in class VectorGraphics2Dstr - Text to be rendered.x - Horizontal position in document units.y - Vertical position in document units.public void setStroke(Stroke s)
setStroke in class VectorGraphics2Dprotected void writeImage(Image img, int imgWidth, int imgHeight, double x, double y, double width, double height)
VectorGraphics2DwriteImage in class VectorGraphics2Dimg - Image to be rendered.imgWidth - Number of pixels in horizontal direction.imgHeight - Number of pixels in vertical directionx - Horizontal position in document units where the
upper left corner of the image should be placed.y - Vertical position in document units where the
upper left corner of the image should be placed.width - Width of the image in document units.height - Height of the image in document units.public void setColor(Color c)
setColor in class VectorGraphics2Dpublic void setClip(Shape clip)
setClip in class VectorGraphics2Dprotected void writeHeader()
VectorGraphics2DwriteHeader in class VectorGraphics2Dprotected void writeDict(Object... strs)
strs - Objects to be written to dictionaryprotected int writeObj(Object... strs)
strs - Objects to be written to the document stream.protected int peekObjId()
protected String getTransparencyResource(double a)
a - Transparency level.protected String getImageResource(BufferedImage bufferedImg)
bufferedImg - Image object with data.protected String getFontResource(Font font)
font - Font to be described.protected void writeClosingDraw(Shape s)
writeClosingDraw in class VectorGraphics2Ds - Shape that should be drawn.protected void writeClosingFill(Shape s)
writeClosingFill in class VectorGraphics2Ds - Shape that should be filled.protected void writeShape(Shape s)
writeShape in class VectorGraphics2Ds - Shape to be written.protected String getFooter()
VectorGraphics2DgetFooter in class VectorGraphics2Dpublic String toString()
toString in class VectorGraphics2Dpublic byte[] getBytes()
VectorGraphics2DgetBytes in class VectorGraphics2DCopyright © 2010-2015. All Rights Reserved.