public class ImageDevice extends Device implements IMultiPageDevice
This class encapsulates rendering of document to image.
Modifier and Type | Field and Description |
---|---|
static String |
BACKGROUND
"Background" property key.
|
static String |
BACKGROUND_COLOR
"Background color" property key.
|
static String |
EMBED_FONTS
"Embed font in document.
|
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 |
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 |
TRANSPARENT
"Transparent" property key.
|
Constructor and Description |
---|
ImageDevice()
Initializes new instance of
ImageDevice . |
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. |
Modifier and Type | Method and Description |
---|---|
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 device.
|
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.
|
Color |
getBackground()
Gets current background of the page.
|
AffineTransform |
getCharTM()
Gets current characters transform.
|
String |
getCreator()
Gets creator of resulting device output.
|
int |
getCurrentPageNumber()
Gets current page number.
|
ITrFont |
getFont()
Gets current font.
|
ImageFormat |
getFormat()
Gets image format.
|
byte[][] |
getImagesBytes()
Gets resulting images in bytes.
|
float |
getOpacity()
Gets current opacity.
|
Paint |
getPaint()
Gets current paint.
|
UserProperties |
getProperties()
Gets device properties including metadata.
|
String |
getProperty(String key)
Gets a value of string property.
|
Color |
getPropertyColor(String key)
Gets a value of color property.
|
double |
getPropertyDouble(String key)
Gets a value of double property.
|
int |
getPropertyInt(String key)
Gets a value of integer property.
|
Insets |
getPropertyMargins(String key)
Gets a value of margins property.
|
Rectangle |
getPropertyRectangle(String key)
Gets a value of rectangle property.
|
Dimension |
getPropertySize(String key)
Gets a value of size property.
|
Dimension |
getSize()
Gets a size of the page.
|
Stroke |
getStroke()
Gets current stroke.
|
TextRenderingMode |
getTextRenderingMode()
Gets current text rendering mode.
|
float |
getTextStrokeWidth()
Gets current text stroke width.
|
AffineTransform |
getTransform()
Gets the current transform.
|
void |
initClip()
Initializes a clip of the device
|
void |
initPageNumbers()
Initializes numbers of pages to output.
|
boolean |
isDirectRGB()
Indicates whether device uses direct RGB mode, that is RGB.
|
boolean |
isProperty(String key)
Gets a value of boolean property.
|
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()
Reset the device to initial state for a 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 |
setBackground(Color bkgrd)
Specifies current background of the page.
|
void |
setCharTM(AffineTransform charTM)
Specifies current characters transform.
|
void |
setClip(Shape path)
Specifies clip shape.
|
void |
setCreator(String creator)
Specifies creator of resulting device output.
|
void |
setFont(ITrFont font)
Specifies current font.
|
void |
setOpacity(float opacity)
Specifies current opacity.
|
void |
setPaint(Paint paint)
Specifies current paint.
|
void |
setProperties(UserProperties props)
Specifies device properties.
|
void |
setSaveOptions(SaveOptions options)
Specifies options for managing rendering process.
|
void |
setSize(Dimension size)
Specifies a size of the page.
|
void |
setStroke(Stroke stroke)
Specifies current stroke.
|
void |
setTextRenderingMode(TextRenderingMode trm)
Specifies current text rendering mode.
|
void |
setTextStrokeWidth(float tsw)
Specifies current text stroke width.
|
void |
setTransform(AffineTransform transform)
Specifies 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 transformation matrix.
|
void |
translate(double x,
double y)
Translates the current transformation matrix.
|
void |
updatePageParameters(IMultiPageDevice doc)
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, getOpacityMask, isLicensed, rotate, setOpacityMask
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.
public static final String EMIT_WARNINGS
"Emit warnings" property key.
public static final String EMIT_ERRORS
"Emit errors" property key.
public static final String PRODUCER
"Producer" property key.
public ImageDevice()
Initializes new instance of ImageDevice
.
public ImageDevice(Dimension size)
Initializes new instance of ImageDevice
with specified size of a page.
size
- Page size.public ImageDevice(Dimension size, ImageFormat imageFormat)
Initializes new instance of ImageDevice
with specified size of a page and image format.
size
- Page size.imageFormat
- Format of the image.public ImageFormat getFormat()
Gets image format.
public void renew()
Reset device to initial state for whole document.
public void setSaveOptions(SaveOptions options)
Specifies options for managing rendering process.
setSaveOptions
in class Device
options
- Rendering options.public void setProperties(UserProperties props)
Specifies device properties.
setProperties
in class Device
props
- Device properties.public UserProperties getProperties()
Gets device properties including metadata.
getProperties
in class Device
public String getProperty(String key)
Gets a value of string property.
getProperty
in class Device
key
- The name of property.public Color getPropertyColor(String key)
Gets a value of color property.
getPropertyColor
in class Device
key
- The name of property.public Rectangle getPropertyRectangle(String key)
Gets a value of rectangle property.
getPropertyRectangle
in class Device
key
- The name of property.public Insets getPropertyMargins(String key)
Gets a value of margins property.
getPropertyMargins
in class Device
key
- The name of property.public Dimension getPropertySize(String key)
Gets a value of size property.
getPropertySize
in class Device
key
- The name of property.public int getPropertyInt(String key)
Gets a value of integer property.
getPropertyInt
in class Device
key
- The name of property.public double getPropertyDouble(String key)
Gets a value of double property.
getPropertyDouble
in class Device
key
- The name of property.public boolean isProperty(String key)
Gets a value of boolean property.
isProperty
in class Device
key
- The name of property.public String getCreator()
Gets creator of resulting device output.
getCreator
in class Device
public void setCreator(String creator)
Specifies creator of resulting device output.
setCreator
in class Device
creator
- The creator.public Dimension getSize()
Gets a size of the page.
public void setSize(Dimension size)
Specifies a size of the page.
public Color getBackground()
Gets current background of the page.
getBackground
in class Device
public void setBackground(Color bkgrd)
Specifies current background of the page.
setBackground
in class Device
bkgrd
- A background.public float getOpacity()
Gets current opacity.
getOpacity
in class Device
public void setOpacity(float opacity)
Specifies current opacity.
setOpacity
in class Device
opacity
- An opacity.public Stroke getStroke()
Gets current stroke.
public void setStroke(Stroke stroke)
Specifies current stroke.
public Paint getPaint()
Gets current paint.
public void setPaint(Paint paint)
Specifies current paint.
public ITrFont getFont()
Gets current font.
public void setFont(ITrFont font)
Specifies current font.
public AffineTransform getCharTM()
Gets current characters transform.
public void setCharTM(AffineTransform charTM)
Specifies current characters transform.
public TextRenderingMode getTextRenderingMode()
Gets current text rendering mode.
getTextRenderingMode
in class Device
public void setTextRenderingMode(TextRenderingMode trm)
Specifies current text rendering mode.
setTextRenderingMode
in class Device
trm
- Text rendering mode.public float getTextStrokeWidth()
Gets current text stroke width.
getTextStrokeWidth
in class Device
public void setTextStrokeWidth(float tsw)
Specifies current text stroke width.
setTextStrokeWidth
in class Device
tsw
- Text stroke width.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 boolean isDirectRGB()
Indicates whether device uses direct RGB mode, that is RGB.
isDirectRGB
in class Device
public void reset()
Reset the device to initial state for a 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 doc)
Updates page parameters from other multi-paged device.
updatePageParameters
in interface IMultiPageDevice
doc
- Another instance of the same device.public Device create()
Creates a copy of this device.
public void initClip()
Initializes a clip of the 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 current transform.
setTransform
in class Device
transform
- A transform.public void transform(AffineTransform transform)
Transforms the current transformation matrix. 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)
Specifies clip shape.
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 writeString(ITrFont font, String str)
Writes out string with specified font.
writeString
in class Device
font
- Specified font.str
- The string.public byte[][] getImagesBytes()
Gets resulting images in bytes.
Copyright © 2021 Aspose. All Rights Reserved.