ImageDevice

Inheritance: java.lang.Object, com.aspose.page.Device

All Implemented Interfaces: com.aspose.page.IMultiPageDevice

public class ImageDevice extends Device implements IMultiPageDevice

This class encapsulates rendering of document to image.

Constructors

ConstructorDescription
ImageDevice()Initializes new instance of ImageDevice .
ImageDevice(ImageFormat imageFormat)Initializes new instance of ImageDevice with specified image format.
ImageDevice(Dimension size)Initializes new instance of ImageDevice with specified size of a page.
ImageDevice(Dimension size, ImageFormat imageFormat)Initializes new instance of ImageDevice with specified size of a page and image format.

Fields

FieldDescription
TRANSPARENT“Transparent” property key.
BACKGROUND“Background” property key.
BACKGROUND_COLOR“Background color” property key.
PAGE_SIZE“Page size” property key.
PAGE_MARGINS“Page margins” property key.
ORIENTATION“Orientation” property key.
FIT_TO_PAGE“Fit content to page” property key.
EMBED_FONTS“Embed font in document.
EMIT_WARNINGS“Emit warnings” property key.
EMIT_ERRORS“Emit errors” property key.
PRODUCER“Producer” property key.

Methods

MethodDescription
getFormat()Gets image format.
renew()Reset device to initial state for whole document.
setSaveOptions(SaveOptions options)Specifies options for managing rendering process.
setProperties(UserProperties props)Specifies device properties.
getProperties()Gets device properties including metadata.
getProperty(String key)Gets a value of string property.
getPropertyColor(String key)Gets a value of color property.
getPropertyRectangle(String key)Gets a value of rectangle property.
getPropertyMargins(String key)Gets a value of margins property.
getPropertySize(String key)Gets a value of size property.
getPropertyInt(String key)Gets a value of integer property.
getPropertyDouble(String key)Gets a value of double property.
isProperty(String key)Gets a value of boolean property.
getCreator()Gets creator of resulting device output.
setCreator(String creator)Specifies creator of resulting device output.
getSize()Gets a size of the page.
setSize(Dimension size)Specifies a size of the page.
getBackground()Gets current background of the page.
setBackground(Color bkgrd)Specifies current background of the page.
getOpacity()Gets current opacity.
setOpacity(float opacity)Specifies current opacity.
getStroke()Gets current stroke.
setStroke(Stroke stroke)Specifies current stroke.
getPaint()Gets current paint.
setPaint(Paint paint)Specifies current paint.
getFont()Gets current font.
setFont(ITrFont font)Specifies current font.
getCharTM()Gets current characters transform.
setCharTM(AffineTransform charTM)Specifies current characters transform.
getTextRenderingMode()Gets current text rendering mode.
setTextRenderingMode(TextRenderingMode trm)Specifies current text rendering mode.
getTextStrokeWidth()Gets current text stroke width.
setTextStrokeWidth(float tsw)Specifies current text stroke width.
startDocument()Makes necessary preparation of device before start rendering of document.
endDocument()Makes necessary preparation of device after the document has been rendered.
dispose()Disposes the device.
isDirectRGB()Indicates whether device uses direct RGB mode, that is RGB.
reset()Reset the device to initial state for a page.
initPageNumbers()Initializes numbers of pages to output.
openPage(String title)Makes necessary preparation of the device before page rendering.
openPage(float width, float height)Makes necessary preparation of the device before page rendering.
closePage()Makes necessary preparation of the device after page has been rendered.
getCurrentPageNumber()Gets current page number.
updatePageParameters(IMultiPageDevice doc)Updates page parameters from other multi-paged device.
create()Creates a copy of this device.
initClip()Initializes a clip of the device
draw(Shape s)Draws a path.
fill(Shape s)Fills a path.
drawImage(BufferedImage image, AffineTransform transform, Color bkg)Draws an image with assigned transform and background.
drawString(String str, float x, float y)Draws a string at given point.
getTransform()Gets the current transform.
setTransform(AffineTransform transform)Specifies current transform.
transform(AffineTransform transform)Transforms the current transformation matrix.
translate(double x, double y)Translates the current transformation matrix.
rotate(double theta)Rotate the current transform over the Z-axis.
scale(double sx, double sy)Scales the current transformation matrix.
shear(double shx, double shy)Shears the current transformation matrix.
setClip(Shape path)Specifies clip shape.
writeComment(String comment)Writes a comment.
toString()Returns the name of device type.
writeString(ITrFont font, String str)Writes out string with specified font.
getImagesBytes()Gets resulting images in bytes.

ImageDevice()

public ImageDevice()

Initializes new instance of ImageDevice .

ImageDevice(ImageFormat imageFormat)

public ImageDevice(ImageFormat imageFormat)

Initializes new instance of ImageDevice with specified image format.

Parameters:

ParameterTypeDescription
imageFormatImageFormatThe format of the image.

ImageDevice(Dimension size)

public ImageDevice(Dimension size)

Initializes new instance of ImageDevice with specified size of a page.

Parameters:

ParameterTypeDescription
sizejava.awt.DimensionPage size.

ImageDevice(Dimension size, ImageFormat imageFormat)

public ImageDevice(Dimension size, ImageFormat imageFormat)

Initializes new instance of ImageDevice with specified size of a page and image format.

Parameters:

ParameterTypeDescription
sizejava.awt.DimensionPage size.
imageFormatImageFormatFormat of the image.

TRANSPARENT

public static final String TRANSPARENT

“Transparent” property key.

BACKGROUND

public static final String BACKGROUND

“Background” property key.

BACKGROUND_COLOR

public static final String BACKGROUND_COLOR

“Background color” property key.

PAGE_SIZE

public static final String PAGE_SIZE

“Page size” property key.

PAGE_MARGINS

public static final String PAGE_MARGINS

“Page margins” property key.

ORIENTATION

public static final String ORIENTATION

“Orientation” property key.

FIT_TO_PAGE

public static final String FIT_TO_PAGE

“Fit content to page” property key.

EMBED_FONTS

public static final String EMBED_FONTS

“Embed font in document.

EMIT_WARNINGS

public static final String EMIT_WARNINGS

“Emit warnings” property key.

EMIT_ERRORS

public static final String EMIT_ERRORS

“Emit errors” property key.

PRODUCER

public static final String PRODUCER

“Producer” property key.

getFormat()

public ImageFormat getFormat()

Gets image format.

Returns: ImageFormat - An image format.

renew()

public void renew()

Reset device to initial state for whole document.

setSaveOptions(SaveOptions options)

public void setSaveOptions(SaveOptions options)

Specifies options for managing rendering process.

Parameters:

ParameterTypeDescription
optionsSaveOptionsRendering options.

setProperties(UserProperties props)

public void setProperties(UserProperties props)

Specifies device properties.

Parameters:

ParameterTypeDescription
propsUserPropertiesDevice properties.

getProperties()

public UserProperties getProperties()

Gets device properties including metadata.

Returns: UserProperties - Device properties.

getProperty(String key)

public String getProperty(String key)

Gets a value of string property.

Parameters:

ParameterTypeDescription
keyjava.lang.StringThe name of property.

Returns: java.lang.String - The property value.

getPropertyColor(String key)

public Color getPropertyColor(String key)

Gets a value of color property.

Parameters:

ParameterTypeDescription
keyjava.lang.StringThe name of property.

Returns: java.awt.Color - The property value.

getPropertyRectangle(String key)

public Rectangle getPropertyRectangle(String key)

Gets a value of rectangle property.

Parameters:

ParameterTypeDescription
keyjava.lang.StringThe name of property.

Returns: java.awt.Rectangle - The property value.

getPropertyMargins(String key)

public Insets getPropertyMargins(String key)

Gets a value of margins property.

Parameters:

ParameterTypeDescription
keyjava.lang.StringThe name of property.

Returns: java.awt.Insets - The property value.

getPropertySize(String key)

public Dimension getPropertySize(String key)

Gets a value of size property.

Parameters:

ParameterTypeDescription
keyjava.lang.StringThe name of property.

Returns: java.awt.Dimension - The property value.

getPropertyInt(String key)

public int getPropertyInt(String key)

Gets a value of integer property.

Parameters:

ParameterTypeDescription
keyjava.lang.StringThe name of property.

Returns: int - The property value.

getPropertyDouble(String key)

public double getPropertyDouble(String key)

Gets a value of double property.

Parameters:

ParameterTypeDescription
keyjava.lang.StringThe name of property.

Returns: double - The property value.

isProperty(String key)

public boolean isProperty(String key)

Gets a value of boolean property.

Parameters:

ParameterTypeDescription
keyjava.lang.StringThe name of property.

Returns: boolean - The property value.

getCreator()

public String getCreator()

Gets creator of resulting device output.

Returns: java.lang.String - The creator.

setCreator(String creator)

public void setCreator(String creator)

Specifies creator of resulting device output.

Parameters:

ParameterTypeDescription
creatorjava.lang.StringThe creator.

getSize()

public Dimension getSize()

Gets a size of the page.

Returns: java.awt.Dimension - Size of the page.

setSize(Dimension size)

public void setSize(Dimension size)

Specifies a size of the page.

Parameters:

ParameterTypeDescription
sizejava.awt.DimensionSize of the page.

getBackground()

public Color getBackground()

Gets current background of the page.

Returns: java.awt.Color - Current background.

setBackground(Color bkgrd)

public void setBackground(Color bkgrd)

Specifies current background of the page.

Parameters:

ParameterTypeDescription
bkgrdjava.awt.ColorA background.

getOpacity()

public float getOpacity()

Gets current opacity.

Returns: float - Current opacity.

setOpacity(float opacity)

public void setOpacity(float opacity)

Specifies current opacity.

Parameters:

ParameterTypeDescription
opacityfloatAn opacity.

getStroke()

public Stroke getStroke()

Gets current stroke.

Returns: java.awt.Stroke - Current stroke.

setStroke(Stroke stroke)

public void setStroke(Stroke stroke)

Specifies current stroke.

Parameters:

ParameterTypeDescription
strokejava.awt.StrokeA stroke.

getPaint()

public Paint getPaint()

Gets current paint.

Returns: java.awt.Paint - Current paint.

setPaint(Paint paint)

public void setPaint(Paint paint)

Specifies current paint.

Parameters:

ParameterTypeDescription
paintjava.awt.PaintA paint.

getFont()

public ITrFont getFont()

Gets current font.

Returns: ITrFont - Current font.

setFont(ITrFont font)

public void setFont(ITrFont font)

Specifies current font.

Parameters:

ParameterTypeDescription
fontITrFontA font.

getCharTM()

public AffineTransform getCharTM()

Gets current characters transform.

Returns: java.awt.geom.AffineTransform - Current characters transform.

setCharTM(AffineTransform charTM)

public void setCharTM(AffineTransform charTM)

Specifies current characters transform.

Parameters:

ParameterTypeDescription
charTMjava.awt.geom.AffineTransformCharacters transform.

getTextRenderingMode()

public TextRenderingMode getTextRenderingMode()

Gets current text rendering mode.

Returns: TextRenderingMode - Current text rendering mode.

setTextRenderingMode(TextRenderingMode trm)

public void setTextRenderingMode(TextRenderingMode trm)

Specifies current text rendering mode.

Parameters:

ParameterTypeDescription
trmTextRenderingModeText rendering mode.

getTextStrokeWidth()

public float getTextStrokeWidth()

Gets current text stroke width.

Returns: float - Current text stroke width.

setTextStrokeWidth(float tsw)

public void setTextStrokeWidth(float tsw)

Specifies current text stroke width.

Parameters:

ParameterTypeDescription
tswfloatText stroke width.

startDocument()

public void startDocument()

Makes necessary preparation of device before start rendering of document.

endDocument()

public void endDocument()

Makes necessary preparation of device after the document has been rendered.

dispose()

public void dispose()

Disposes the device.

isDirectRGB()

public boolean isDirectRGB()

Indicates whether device uses direct RGB mode, that is RGB.

Returns: boolean - True if direct RGB mode and false otherwise, that is BGR.

reset()

public void reset()

Reset the device to initial state for a page.

initPageNumbers()

public void initPageNumbers()

Initializes numbers of pages to output.

openPage(String title)

public boolean openPage(String title)

Makes necessary preparation of the device before page rendering.

Parameters:

ParameterTypeDescription
titlejava.lang.StringThe page title.

Returns: boolean - Always true.

openPage(float width, float height)

public boolean openPage(float width, float height)

Makes necessary preparation of the device before page rendering.

Parameters:

ParameterTypeDescription
widthfloatA width of the page.
heightfloatA height of the page.

Returns: boolean - Always true.

closePage()

public final void closePage()

Makes necessary preparation of the device after page has been rendered.

getCurrentPageNumber()

public int getCurrentPageNumber()

Gets current page number.

Returns: int - Current page number.

updatePageParameters(IMultiPageDevice doc)

public void updatePageParameters(IMultiPageDevice doc)

Updates page parameters from other multi-paged device.

Parameters:

ParameterTypeDescription
docIMultiPageDeviceAnother instance of the same device.

create()

public Device create()

Creates a copy of this device.

Returns: Device

initClip()

public void initClip()

Initializes a clip of the device

draw(Shape s)

public void draw(Shape s)

Draws a path.

Parameters:

ParameterTypeDescription
sjava.awt.ShapeA path to be drawn.

fill(Shape s)

public void fill(Shape s)

Fills a path.

Parameters:

ParameterTypeDescription
sjava.awt.ShapeA path to be filled.

drawImage(BufferedImage image, AffineTransform transform, Color bkg)

public void drawImage(BufferedImage image, AffineTransform transform, Color bkg)

Draws an image with assigned transform and background.

Parameters:

ParameterTypeDescription
imagejava.awt.image.BufferedImageAn image to be drawn.
transformjava.awt.geom.AffineTransformA transform.
bkgjava.awt.ColorA background color.

drawString(String str, float x, float y)

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

Draws a string at given point.

Parameters:

ParameterTypeDescription
strjava.lang.StringA string to be drawn.
xfloatX coordinate of point.
yfloatY coordinate of point.

getTransform()

public AffineTransform getTransform()

Gets the current transform.

Returns: java.awt.geom.AffineTransform - current transform.

setTransform(AffineTransform transform)

public void setTransform(AffineTransform transform)

Specifies current transform.

Parameters:

ParameterTypeDescription
transformjava.awt.geom.AffineTransformA transform.

transform(AffineTransform transform)

public void transform(AffineTransform transform)

Transforms the current transformation matrix. Calls writeTransform(Transform).

Parameters:

ParameterTypeDescription
transformjava.awt.geom.AffineTransformTransform to be applied.

translate(double x, double y)

public void translate(double x, double y)

Translates the current transformation matrix. Calls writeTransform(Transform).

Parameters:

ParameterTypeDescription
xdoubleTranslation in X axis.
ydoubleTranslation in Y axis.

rotate(double theta)

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.

Parameters:

ParameterTypeDescription
thetadoubleradians over which to rotate

scale(double sx, double sy)

public void scale(double sx, double sy)

Scales the current transformation matrix. Calls writeTransform(Transform).

Parameters:

ParameterTypeDescription
sxdoubleA scale in X axis.
sydoubleA scale in Y axis.

shear(double shx, double shy)

public void shear(double shx, double shy)

Shears the current transformation matrix. Calls writeTransform(Transform).

Parameters:

ParameterTypeDescription
shxdoubleA shear in X axis.
shydoubleA shear in Y axis.

setClip(Shape path)

public void setClip(Shape path)

Specifies clip shape.

Parameters:

ParameterTypeDescription
pathjava.awt.ShapePath that is used for clipping.

writeComment(String comment)

public void writeComment(String comment)

Writes a comment.

Parameters:

ParameterTypeDescription
commentjava.lang.StringA comment to be written.

toString()

public String toString()

Returns the name of device type.

Returns: java.lang.String - Type name.

writeString(ITrFont font, String str)

public void writeString(ITrFont font, String str)

Writes out string with specified font.

Parameters:

ParameterTypeDescription
fontITrFontSpecified font.
strjava.lang.StringThe string.

getImagesBytes()

public byte[][] getImagesBytes()

Gets resulting images in bytes.

Returns: byte[][] - Images bytes. One byte array for one page.