PdfDevice

Inheritance: java.lang.Object, com.aspose.page.Device, com.aspose.xps.rendering.DeviceXps

All Implemented Interfaces: com.aspose.page.IMultiPartitionDevice, com.aspose.page.IInteractiveDevice

public class PdfDevice extends DeviceXps implements IMultiPartitionDevice, IInteractiveDevice

Class incapsulating image composing device.

Constructors

ConstructorDescription
PdfDevice(OutputStream stream)Creates the new instance.
PdfDevice(OutputStream stream, Dimension pageSize)Creates the new instance with specified media size.

Methods

MethodDescription
renew()Sets the devices to the initial state.
setSaveOptions(SaveOptions value)Initializes save options.
getSize()Gets the device media size.
setSize(Dimension value)Sets the device media size.
getBackground()Gets the background color.
setBackground(Color value)Sets the background color.
getOpacity()Gets the opacity.
setOpacity(float value)Sets the opacity.
getStroke()Gets the stroke for drawing paths.
setStroke(Stroke value)Sets the stroke for drawing paths.
getPaint()Gets the brush for filling paths.
setPaint(Paint value)Sets the brush for filling paths.
getOpacityMask()Gets the brush for opacity mask.
setOpacityMask(Paint value)Gets the brush for opacity mask.
getFont()Gets the current font.
setFont(ITrFont value)Sets the current font.
startDocument()Starts the document.
endDocument()Accomplishes the document.
reset()Resets the device.
initPageNumbers()Initializes numbers of pages to output.
openPage(String title)Starts a new page with the specifies title.
openPage(float width, float height)Starts a new page with the specified width and height.
closePage()Accomplishes the page.
updatePageParameters(IMultiPageDevice device)Updates the current page parameters.
getCurrentPageNumber()Returns the absolute number of the current page within the document.
getCurrentRelativePageNumber()Returns the relative number of the current page within the current partition.
openPartition()Starts a new document partition.
closePartition()Accomplished the document partition.
setHyperlinkTarget(String targetUri)Sets the hyperlink with an external URI as its target.
setHyperlinkTarget(int targetPageNumber)Sets the hyperlink with a page number as its target.
addOutline(int outlineLevel, String description)Adds an outline item with the last object as its target.
addOutline(Point2D origin, int outlineLevel, String description)Adds an outline item with the origin point as its target.
create()Creates a new instance of the device based on this device instance.
dispose()Disposes this device instance.
getTransform()Returns the current transformation matrix.
setTransform(AffineTransform transform)Sets the current transformation matrix.
transform(AffineTransform transform)Multiplies the current transformation matrix by the specified Matrix .
translate(double x, double y)Applies the specified translation vector to the current transformation matrix.
rotate(double theta)Applies a clockwise rotation about the origin to the current transformation matrix.
scale(double x, double y)Applies the specified scale vector to the current transformation matrix.
shear(double shx, double shy)Applies the specified shear vector to the current transformation matrix.
setClip(Shape clipPath)Adds the specified path to the current clip path.
draw(Shape path)Draws the specified path.
fill(Shape path)Fills the specified path.
drawString(String str, float x, float y)Draws a string at the specified position.

PdfDevice(OutputStream stream)

public PdfDevice(OutputStream stream)

Creates the new instance.

Parameters:

ParameterTypeDescription
streamjava.io.OutputStreamThe output stream containing PDF.

PdfDevice(OutputStream stream, Dimension pageSize)

public PdfDevice(OutputStream stream, Dimension pageSize)

Creates the new instance with specified media size.

Parameters:

ParameterTypeDescription
streamjava.io.OutputStreamThe output stream containing PDF.
pageSizejava.awt.DimensionThe size of the device output media.

renew()

public void renew()

Sets the devices to the initial state.

setSaveOptions(SaveOptions value)

public void setSaveOptions(SaveOptions value)

Initializes save options.

Parameters:

ParameterTypeDescription
valueSaveOptionsSave options.

getSize()

public Dimension getSize()

Gets the device media size.

Returns: java.awt.Dimension - The device media size.

setSize(Dimension value)

public void setSize(Dimension value)

Sets the device media size.

Parameters:

ParameterTypeDescription
valuejava.awt.DimensionThe device media size.

getBackground()

public Color getBackground()

Gets the background color.

Returns: java.awt.Color - The background color.

setBackground(Color value)

public void setBackground(Color value)

Sets the background color.

Parameters:

ParameterTypeDescription
valuejava.awt.ColorThe background color.

getOpacity()

public float getOpacity()

Gets the opacity.

Returns: float - The opacity.

setOpacity(float value)

public void setOpacity(float value)

Sets the opacity.

Parameters:

ParameterTypeDescription
valuefloatThe opacity.

getStroke()

public Stroke getStroke()

Gets the stroke for drawing paths.

Returns: java.awt.Stroke - The stroke for drawing paths.

setStroke(Stroke value)

public void setStroke(Stroke value)

Sets the stroke for drawing paths.

Parameters:

ParameterTypeDescription
valuejava.awt.StrokeThe stroke for drawing paths.

getPaint()

public Paint getPaint()

Gets the brush for filling paths.

Returns: java.awt.Paint - The brush for filling paths.

setPaint(Paint value)

public void setPaint(Paint value)

Sets the brush for filling paths.

Parameters:

ParameterTypeDescription
valuejava.awt.PaintThe brush for filling paths.

getOpacityMask()

public Paint getOpacityMask()

Gets the brush for opacity mask. The mask applies over Paint or Strike.

Returns: java.awt.Paint - The brush for opacity mask.

setOpacityMask(Paint value)

public void setOpacityMask(Paint value)

Gets the brush for opacity mask. The mask applies over Paint or Strike.

Parameters:

ParameterTypeDescription
valuejava.awt.PaintThe brush for opacity mask.

getFont()

public ITrFont getFont()

Gets the current font.

Returns: ITrFont - The current font.

setFont(ITrFont value)

public void setFont(ITrFont value)

Sets the current font.

Parameters:

ParameterTypeDescription
valueITrFontThe current font.

startDocument()

public void startDocument()

Starts the document.

endDocument()

public void endDocument()

Accomplishes the document.

reset()

public void reset()

Resets the device.

initPageNumbers()

public void initPageNumbers()

Initializes numbers of pages to output.

openPage(String title)

public boolean openPage(String title)

Starts a new page with the specifies title.

Parameters:

ParameterTypeDescription
titlejava.lang.StringThe title.

Returns: boolean - True if started page is to be output (it’s number is contained in PageNumbers save options). False , otherwise.

openPage(float width, float height)

public boolean openPage(float width, float height)

Starts a new page with the specified width and height.

Parameters:

ParameterTypeDescription
widthfloatThe width of the page.
heightfloatThe height of the page.

Returns: boolean - True if started page is to be output (it’s number is contained in PageNumbers save options). False , otherwise.

closePage()

public void closePage()

Accomplishes the page.

updatePageParameters(IMultiPageDevice device)

public void updatePageParameters(IMultiPageDevice device)

Updates the current page parameters.

Parameters:

ParameterTypeDescription
deviceIMultiPageDeviceThe multipage device.

getCurrentPageNumber()

public int getCurrentPageNumber()

Returns the absolute number of the current page within the document.

Returns: int - The absolute number of the current page.

getCurrentRelativePageNumber()

public int getCurrentRelativePageNumber()

Returns the relative number of the current page within the current partition.

Returns: int - The relative number of the current page.

openPartition()

public void openPartition()

Starts a new document partition.

closePartition()

public void closePartition()

Accomplished the document partition.

setHyperlinkTarget(String targetUri)

public void setHyperlinkTarget(String targetUri)

Sets the hyperlink with an external URI as its target.

Parameters:

ParameterTypeDescription
targetUrijava.lang.StringThe target external URI.

setHyperlinkTarget(int targetPageNumber)

public void setHyperlinkTarget(int targetPageNumber)

Sets the hyperlink with a page number as its target.

Parameters:

ParameterTypeDescription
targetPageNumberintThe target page number.

addOutline(int outlineLevel, String description)

public void addOutline(int outlineLevel, String description)

Adds an outline item with the last object as its target.

Parameters:

ParameterTypeDescription
outlineLevelintThe outline level.
descriptionjava.lang.StringThe item description.

addOutline(Point2D origin, int outlineLevel, String description)

public void addOutline(Point2D origin, int outlineLevel, String description)

Adds an outline item with the origin point as its target.

Parameters:

ParameterTypeDescription
originjava.awt.geom.Point2DThe target origin.
outlineLevelintThe outline level.
descriptionjava.lang.StringThe item description.

create()

public Device create()

Creates a new instance of the device based on this device instance. Writes this device graphics state, i.e. creates ApsCanvas instance(s) with corresponding RenderTransform and Clip properties.

Returns: Device - The new device instance.

dispose()

public void dispose()

Disposes this device instance. Finalizes this device instance graphics state, i.e. switches APS composing context to the ApsCanvas of the level higher then this device’s graphics state ApsCanvas .

getTransform()

public AffineTransform getTransform()

Returns the current transformation matrix.

Returns: java.awt.geom.AffineTransform - The current transformation matrix.

setTransform(AffineTransform transform)

public void setTransform(AffineTransform transform)

Sets the current transformation matrix.

Parameters:

ParameterTypeDescription
transformjava.awt.geom.AffineTransformThe new transformation matrix.

transform(AffineTransform transform)

public void transform(AffineTransform transform)

Multiplies the current transformation matrix by the specified Matrix .

Parameters:

ParameterTypeDescription
transformjava.awt.geom.AffineTransformThe matrix by which the current transformation matrix is to be multiplied.

translate(double x, double y)

public void translate(double x, double y)

Applies the specified translation vector to the current transformation matrix.

Parameters:

ParameterTypeDescription
xdoubleThe x offset.
ydoubleThe y offset.

rotate(double theta)

public void rotate(double theta)

Applies a clockwise rotation about the origin to the current transformation matrix.

Parameters:

ParameterTypeDescription
thetadoubleThe angle of the rotation, in radians.

scale(double x, double y)

public void scale(double x, double y)

Applies the specified scale vector to the current transformation matrix.

Parameters:

ParameterTypeDescription
xdoubleThe x scale factor.
ydoubleThe y scale factor.

shear(double shx, double shy)

public void shear(double shx, double shy)

Applies the specified shear vector to the current transformation matrix.

Parameters:

ParameterTypeDescription
shxdoubleThe x shear factor.
shydoubleThe y shear factor.

setClip(Shape clipPath)

public void setClip(Shape clipPath)

Adds the specified path to the current clip path.

Parameters:

ParameterTypeDescription
clipPathjava.awt.ShapeThe clip path to be added.

draw(Shape path)

public void draw(Shape path)

Draws the specified path.

Parameters:

ParameterTypeDescription
pathjava.awt.ShapeThe path to draw.

fill(Shape path)

public void fill(Shape path)

Fills the specified path.

Parameters:

ParameterTypeDescription
pathjava.awt.ShapeThe path to fill.

drawString(String str, float x, float y)

public void drawString(String str, float x, float y)

Draws a string at the specified position.

Parameters:

ParameterTypeDescription
strjava.lang.StringThe text.
xfloatThe x-coordinate of the string position.
yfloatThe y-coordinate of the string position.