public class PdfDevice extends Device implements IMultiPageDevice, IStreamable
This class encapsulates rendering of document to PDF.
Modifier and Type | Field and Description |
---|---|
static String |
AUTHOR
"Author" property key.
|
static String |
BACKGROUND
"Background" property key.
|
static String |
BACKGROUND_COLOR
"Background color" property key.
|
static String |
COMPRESS
"Compress" property key.
|
static String |
EMBED_FONTS
"Embed font in document" property key.
|
static String |
EMBED_FONTS_AS
"What font type is used for embedding" property key.
|
static String |
EMIT_ERRORS
"Emit errors" property key.
|
static String |
EMIT_WARNINGS
"Emit warnings" property key.
|
static String |
FIT_TO_PAGE
"Fit content to page" property key.
|
static String |
KEYWORDS
"Keywords" property key.
|
static String |
ORIENTATION
"Orientation" property key.
|
static String |
PAGE_MARGINS
"Page margins" property key.
|
static String |
PAGE_SIZE
"Page size" property key.
|
static String |
PRODUCER
"Producer" property key.
|
static String |
SUBJECT
"Subject" property key.
|
static String |
TITLE
"Title" property key.
|
static String |
TRANSPARENT
"Transparent" property key.
|
static String |
VERSION
"Version" property key.
|
static String |
VERSION5
"Version of Adobe Acrobat Reader" property value.
|
static String |
WRITE_IMAGES_AS
"Format of images" property key.
|
Constructor and Description |
---|
PdfDevice(OutputStream ros)
Initializes new instance of
PdfDevice with an output stream. |
PdfDevice(OutputStream ros,
Dimension size)
Initializes new instance of
PdfDevice with an output stream. |
Modifier and Type | Method and Description |
---|---|
void |
clip(Shape s)
Clips using given shape.
|
void |
clipRect(float x,
float y,
float width,
float height)
Clips rectangle.
|
void |
closePage()
Makes necessary preparation of the device after page has been rendered.
|
Device |
create()
Creates a copy of this device.
|
void |
dispose()
Disposes the graphics context.
|
void |
draw(Shape s)
Draws a path.
|
void |
drawImage(BufferedImage image,
AffineTransform transform,
Color bkg)
Draws an image with assigned transform and background.
|
void |
drawString(String str,
float x,
float y)
Draws a string at given point.
|
void |
endDocument()
Makes necessary preparation of device after the document has been rendered.
|
void |
fill(Shape s)
Fills a path.
|
int |
getCurrentPageNumber()
Gets current page number.
|
OutputStream |
getOutputStream()
Gets an output stream.
|
UserProperties |
getProperties()
Gets device properties including metadata.
|
AffineTransform |
getTransform()
Gets the current transform.
|
void |
initClip()
Initializes clip of the device.
|
void |
initPageNumbers()
Initializes numbers of pages to output.
|
boolean |
openPage(float width,
float height)
Makes necessary preparation of the device before page rendering.
|
boolean |
openPage(String title)
Makes necessary preparation of the device before page rendering.
|
void |
renew()
Reset device to initial state for whole document.
|
void |
reset()
If page device parameters will be set this method allows to return writing stream back the begining of page.
|
void |
rotate(double theta)
Rotate the current transform over the Z-axis.
|
void |
scale(double sx,
double sy)
Scales the current transformation matrix.
|
void |
setClip(Shape path)
Specifies clip shape.
|
void |
setFont(ITrFont font)
Specifies current font.
|
void |
setOutputStream(OutputStream os)
Specifies an output stream.
|
void |
setPaint(Paint paint)
Specifies current paint.
|
void |
setProperties(Properties props)
Specifies device properties including metadata.
|
void |
setTransform(AffineTransform transform)
Specifies the current transform.
|
void |
shear(double shx,
double shy)
Shears the current transformation matrix.
|
void |
startDocument()
Makes necessary preparation of device before start rendering of document.
|
String |
toString()
Returns the name of device type.
|
void |
transform(AffineTransform transform)
Transforms the current transform.
|
void |
translate(double x,
double y)
Translates the current transformation matrix.
|
void |
updatePageParameters(IMultiPageDevice device)
Updates page parameters from other multi-paged device.
|
void |
writeComment(String comment)
Writes a comment.
|
void |
writeString(ITrFont font,
String str)
Writes out string with specified font.
|
drawArc, drawLine, drawOval, drawPolygon, drawPolygon, drawPolyline, drawPolyline, drawRect, drawRoundRect, fillArc, fillOval, fillPolygon, fillPolygon, fillRect, fillRoundRect, getBackground, getCharTM, getCreator, getFont, getOpacity, getOpacityMask, getPaint, getProperty, getPropertyColor, getPropertyDouble, getPropertyInt, getPropertyMargins, getPropertyRectangle, getPropertySize, getSize, getStroke, getTextRenderingMode, getTextStrokeWidth, isDirectRGB, isLicensed, isProperty, rotate, setBackground, setCharTM, setCreator, setOpacity, setOpacityMask, setProperties, setSaveOptions, setSize, setStroke, setTextRenderingMode, setTextStrokeWidth
public static final String VERSION
"Version" property key.
public static final String VERSION5
"Version of Adobe Acrobat Reader" property value.
public static final String TRANSPARENT
"Transparent" property key.
public static final String BACKGROUND
"Background" property key.
public static final String BACKGROUND_COLOR
"Background color" property key.
public static final String PAGE_SIZE
"Page size" property key.
public static final String PAGE_MARGINS
"Page margins" property key.
public static final String ORIENTATION
"Orientation" property key.
public static final String FIT_TO_PAGE
"Fit content to page" property key.
public static final String EMBED_FONTS
"Embed font in document" property key.
public static final String EMBED_FONTS_AS
"What font type is used for embedding" property key.
public static final String COMPRESS
"Compress" property key.
public static final String WRITE_IMAGES_AS
"Format of images" property key.
public static final String PRODUCER
"Producer" property key.
public static final String AUTHOR
"Author" property key.
public static final String TITLE
"Title" property key.
public static final String SUBJECT
"Subject" property key.
public static final String KEYWORDS
"Keywords" property key.
public static final String EMIT_WARNINGS
"Emit warnings" property key.
public static final String EMIT_ERRORS
"Emit errors" property key.
public PdfDevice(OutputStream ros)
Initializes new instance of PdfDevice
with an output stream.
ros
- An output stream.public PdfDevice(OutputStream ros, Dimension size)
Initializes new instance of PdfDevice
with an output stream.
ros
- An output stream.size
- Page size.public UserProperties getProperties()
Gets device properties including metadata.
getProperties
in class Device
public void setProperties(Properties props)
Specifies device properties including metadata.
props
- Device properties.public void renew()
Reset device to initial state for whole document. Used for reseting output stream.
public void startDocument()
Makes necessary preparation of device before start rendering of document.
startDocument
in class Device
public void endDocument()
Makes necessary preparation of device after the document has been rendered.
endDocument
in class Device
public void dispose()
Disposes the graphics context. If on creation restoreOnDispose was true, writeGraphicsRestore() will be called.
public void reset()
If page device parameters will be set this method allows to return writing stream back the begining of page.
public void initPageNumbers()
Initializes numbers of pages to output.
initPageNumbers
in interface IMultiPageDevice
public boolean openPage(String title)
Makes necessary preparation of the device before page rendering.
openPage
in interface IMultiPageDevice
title
- The page title.public boolean openPage(float width, float height)
Makes necessary preparation of the device before page rendering.
openPage
in interface IMultiPageDevice
width
- A width of the page.height
- A height of the page.public void closePage()
Makes necessary preparation of the device after page has been rendered.
closePage
in interface IMultiPageDevice
public int getCurrentPageNumber()
Gets current page number.
getCurrentPageNumber
in interface IMultiPageDevice
public void updatePageParameters(IMultiPageDevice device)
Updates page parameters from other multi-paged device.
updatePageParameters
in interface IMultiPageDevice
device
- Another instance of the same device.public Device create()
Creates a copy of this device.
public void draw(Shape s)
Draws a path.
public void fill(Shape s)
Fills a path.
public void drawImage(BufferedImage image, AffineTransform transform, Color bkg)
Draws an image with assigned transform and background.
public void drawString(String str, float x, float y)
Draws a string at given point.
drawString
in class Device
str
- A string to be drawn.x
- X coordinate of point.y
- Y coordinate of point.public AffineTransform getTransform()
Gets the current transform.
getTransform
in class Device
public void setTransform(AffineTransform transform)
Specifies the current transform. Since most output formats do not implement this functionality, the inverse transform of the currentTransform is calculated and multiplied by the transform to be set. The result is then forwarded by a call to writeTransform(Transform).
setTransform
in class Device
transform
- Transform to be applied.public void transform(AffineTransform transform)
Transforms the current transform. Calls writeTransform(Transform)
public void translate(double x, double y)
Translates the current transformation matrix. Calls writeTransform(Transform).
public void rotate(double theta)
Rotate the current transform over the Z-axis. Calls writeTransform(Transform). Rotating with a positive angle theta rotates points on the positive x axis toward the positive y axis.
public void scale(double sx, double sy)
Scales the current transformation matrix. Calls writeTransform(Transform).
public void shear(double shx, double shy)
Shears the current transformation matrix. Calls writeTransform(Transform).
public void setClip(Shape path)
public void setPaint(Paint paint)
Specifies current paint.
public void clipRect(float x, float y, float width, float height)
Clips rectangle. Calls clip(Rectangle2D).
x
- The x-coordinate.y
- The y-coordinate.width
- The rectangle width.height
- The rectangle height.public void writeComment(String comment)
Writes a comment.
writeComment
in class Device
comment
- A comment to be written.public String toString()
Returns the name of device type.
public void clip(Shape s)
Clips using given shape. Dispatches to writeClip(Rectangle), writeClip(Rectangle2D) or writeClip(Shape).
s
- Shape used for clipping.public void setFont(ITrFont font)
Specifies current font.
public void writeString(ITrFont font, String str)
Writes out string with specified font.
writeString
in class Device
font
- Specified font.str
- The string.public OutputStream getOutputStream()
Gets an output stream.
getOutputStream
in interface IStreamable
public void setOutputStream(OutputStream os)
Specifies an output stream.
setOutputStream
in interface IStreamable
os
- An output stream.Copyright © 2021 Aspose. All Rights Reserved.