public abstract class PdfImage extends PdfStream
PdfImage currently supports Joint Photographic Experts
Group (JPEG), bitmap (BMP), and Portable Network Graphics (PNG)
image formats.
Methods of this class can:
After creating an object of this class, you can use methods such as
drawImage of PdfPage or PdfDocument
instances to add images. The object's height and width will be
interpreted in terms of current measurement unit of the page or
document. See
example.
| Modifier and Type | Method and Description |
|---|---|
int |
bitsPerComponent()
Returns number of bits used to store value of each component of
colorspace for this image.
|
static PdfImage |
create(FileImageInputStream imageStream)
Creates a
PdfImage object with specified
FileImageInputStream object. |
static PdfImage |
create(RenderedImage renderedImage)
Creates a
PdfImage object with specified
RenderedImage object. |
static PdfImage |
create(String path)
Creates a
PdfImage object based on image file
specified by path. |
PdfObject |
getColorSpace() |
float |
getHeight()
Retrieves height currently set for this object.
|
float |
getRotation()
Retrieves rotation angle currently set for this object.
|
float |
getWidth()
Retrieves width currently set for this object.
|
int |
hashCode() |
float |
height()
Retrieves original height of image.
|
void |
setHeight(double height)
Specifies height for this object.
|
void |
setRotation(double r)
Specifies rotation angle for this object.
|
void |
setWidth(double width)
Specifies width for this object.
|
float |
width()
Retrieves original width of image.
|
clone, decompress, equals, getBuffer, getDecodeParms, getDictionary, getFilters, setBuffer, toStringgetGenerationNumber, getObjectNumber, setGenerationNumber, setObjectNumberpublic static PdfImage create(String path) throws IOException, PdfException
PdfImage object based on image file
specified by path.path - relative or fully qualified path and filename of
the imagePdfImage objectIOException - if an I/O error occurs.PdfException - if an illegal argument is supplied.public static PdfImage create(FileImageInputStream imageStream) throws IOException, PdfException
PdfImage object with specified
FileImageInputStream object.imageStream - image with which the PdfImage object
needs to be createdPdfImage objectIOException - if an I/O error occurs.PdfException - if an illegal argument is supplied.public static PdfImage create(RenderedImage renderedImage) throws PdfException, IOException
PdfImage object with specified
RenderedImage object.renderedImage - RenderedImage object that needs to be
used for creating this imagePdfImage objectPdfException - if an illegal argument is supplied.IOException - if an I/O error occurs.public void setWidth(double width)
width - width in current measurement unitpublic float getWidth()
public void setHeight(double height)
height - height in current measurement unitpublic float getHeight()
public void setRotation(double r)
r - angle of rotation in degrees (Made with reference to
center of image. Applied in anti-clockwise
direction.)public float getRotation()
public int bitsPerComponent()
public PdfObject getColorSpace()
public float width()
public float height()