public class PdfDevice extends Device implements IInteractiveDevice, IFragmentRasterizer
Implements the interface for outputting text and graphic content to PDF document.
Modifier | Constructor and Description |
---|---|
|
PdfDevice()
Creates new instance.
|
|
PdfDevice(OutputStream stream)
Creates new instance.
|
protected |
PdfDevice(PdfDevice device)
Clone constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addBookmark(String name,
Point2D position)
Adds the bookmark identified by the name.
|
void |
addHyperlink(Rectangle2D activeRect,
ColoredStroke border,
String targetUri)
Sets the hyperlink with a URI as its target.
|
Device |
create()
Creates a copy of this device.
|
void |
dispose()
Disposes the device.
|
void |
drawPath(Shape path)
Draws a path.
|
void |
drawString(String str,
float originX,
float originY,
List<GlyphData> charInfos)
Draws a text string.
|
void |
endDocument()
Finalizes the whole document.
|
void |
endFragment()
Ends a fragment to rasterize.
|
void |
endPage()
Finalizes a page.
|
void |
fillPath(Shape path)
Fills a path.
|
String |
getDestinationName()
Gets destination name: output file name or device description.
|
Color |
getFill()
Gets the current fill color.
|
float |
getFillOpacity()
Gets the current fill opacity.
|
int |
getPageCount()
Gets the number of pages.
|
ColoredStroke |
getStroke()
Gets the current stroke.
|
float |
getStrokeOpacity()
Gets the current stroke opacity.
|
void |
init()
Initializes device.
|
boolean |
isReady()
Shows if device is ready for output.
|
void |
setClip(Shape path)
Sets the current clip path.
|
void |
setFill(Color value)
Sets the current fill color.
|
void |
setFillOpacity(float value)
Sets the current fill opacity.
|
void |
setStroke(ColoredStroke value)
Sets the current stroke.
|
void |
setStrokeOpacity(float value)
Sets the current stroke opacity.
|
void |
setTransform(AffineTransform matrix)
Sets the current coordinate space transformation.
|
void |
showImage(Point2D origin,
Dimension2D size,
byte[] imageData)
Shows a raster image.
|
void |
startDocument()
Starts the whole document.
|
void |
startFragment()
Starts a fragment to rasterize.
|
void |
startPage(float width,
float height)
Starts a new page.
|
restoreGraphicsState, saveGraphicsState
public PdfDevice()
Creates new instance. The output file will be written to the output working directory taking the job name as a file name.
public PdfDevice(OutputStream stream)
Creates new instance. The output file will be written to specified stream.
stream
- The stream to write the output file to.protected PdfDevice(PdfDevice device)
Clone constructor. Initializes this device with another device.
device
- The device to clone.public int getPageCount()
Gets the number of pages.
getPageCount
in class Device
public boolean isReady()
Shows if device is ready for output.
public String getDestinationName()
Gets destination name: output file name or device description.
getDestinationName
in class Device
public Device create()
Creates a copy of this device.
public void startDocument()
Starts the whole document.
startDocument
in class Device
public void endDocument()
Finalizes the whole document.
endDocument
in class Device
public void startPage(float width, float height)
Starts a new page.
public void addHyperlink(Rectangle2D activeRect, ColoredStroke border, String targetUri)
Sets the hyperlink with a URI as its target.
addHyperlink
in class Device
activeRect
- The active rectangle of the link.border
- The link border.targetUri
- The target URI.public void addBookmark(String name, Point2D position)
Adds the bookmark identified by the name.
addBookmark
in interface IInteractiveDevice
name
- The bookmark name.position
- The bookmark position.public void setTransform(AffineTransform matrix)
Sets the current coordinate space transformation.
setTransform
in class Device
matrix
- The transformation matrix.public void setClip(Shape path)
Sets the current clip path.
public ColoredStroke getStroke()
Gets the current stroke.
public void setStroke(ColoredStroke value)
Sets the current stroke.
public Color getFill()
Gets the current fill color.
public void setFill(Color value)
Sets the current fill color.
public float getStrokeOpacity()
Gets the current stroke opacity.
getStrokeOpacity
in class Device
public void setStrokeOpacity(float value)
Sets the current stroke opacity.
setStrokeOpacity
in class Device
value
- The current stroke opacity.public float getFillOpacity()
Gets the current fill opacity.
getFillOpacity
in class Device
public void setFillOpacity(float value)
Sets the current fill opacity.
setFillOpacity
in class Device
value
- The current fill opacity.public void drawString(String str, float originX, float originY, List<GlyphData> charInfos)
Draws a text string.
drawString
in class Device
str
- The string.originX
- The x coordinate of the origin.originY
- The x coordinate of the origin.charInfos
- Glyph data required for precise typesetting of a text string.public void drawPath(Shape path)
Draws a path.
public void fillPath(Shape path)
Fills a path.
public void showImage(Point2D origin, Dimension2D size, byte[] imageData)
Shows a raster image.
public void startFragment()
Starts a fragment to rasterize.
startFragment
in interface IFragmentRasterizer
public void endFragment()
Ends a fragment to rasterize.
endFragment
in interface IFragmentRasterizer