public class PdfImageXObject extends PdfXObject
| Modifier and Type | Class and Description |
|---|---|
static class |
PdfImageXObject.ImageBytesRetrievalProperties
Manages the steps taken in extracting the image.
|
| Constructor and Description |
|---|
PdfImageXObject(ImageData image)
Creates Image XObject by image.
|
PdfImageXObject(ImageData image,
PdfImageXObject imageMask)
Creates Image XObject by image.
|
PdfImageXObject(PdfStream pdfStream)
Create
PdfImageXObject instance by PdfStream. |
| Modifier and Type | Method and Description |
|---|---|
PdfImageXObject |
copyTo(PdfDocument document)
Copy Image XObject to the specified document.
|
void |
flush()
To manually flush a
PdfObject behind this wrapper, you have to ensure
that this object is added to the document, i.e. |
BufferedImage |
getBufferedImage()
Gets image bytes, wrapped with buffered image.
|
float |
getHeight()
Gets height of image,
Height key. |
byte[] |
getImageBytes()
Gets decoded image bytes.
|
byte[] |
getImageBytes(boolean decoded)
Gets image bytes.
|
byte[] |
getImageBytes(PdfImageXObject.ImageBytesRetrievalProperties properties)
Gets image bytes.
|
float |
getWidth()
Gets width of image,
Width key. |
String |
identifyImageFileExtension()
Identifies recommended file extension to store the bytes of this
PdfImageXObject. |
String |
identifyImageFileExtension(PdfImageXObject.ImageBytesRetrievalProperties properties)
Identifies recommended file extension to store the bytes of this
PdfImageXObject. |
ImageType |
identifyImageType()
Identifies the type of the image that is stored in the bytes of this
PdfImageXObject. |
ImageType |
identifyImageType(PdfImageXObject.ImageBytesRetrievalProperties properties)
Identifies the type of the image that is stored in the bytes of this
PdfImageXObject. |
boolean |
isMask()
Returns whether this image is a mask that can be used for other images.
|
boolean |
isSoftMask()
Returns whether this image is a soft mask that can be used for other images.
|
PdfImageXObject |
put(PdfName key,
PdfObject value)
Puts the value into Image XObject dictionary and associates it with the specified key.
|
addAssociatedFile, calculateProportionallyFitRectangleWithHeight, calculateProportionallyFitRectangleWithWidth, getAssociatedFiles, isWrappedObjectMustBeIndirect, makeXObject, setLayerensureObjectIsAddedToDocument, ensureUnderlyingObjectHasIndirectReference, getPdfObject, isFlushed, makeIndirect, makeIndirect, markObjectAsIndirect, setForbidRelease, setModified, setPdfObject, unsetForbidReleasepublic PdfImageXObject(ImageData image)
image - ImageData with actual image data.public PdfImageXObject(ImageData image, PdfImageXObject imageMask)
image - ImageData with actual image data.imageMask - PdfImageXObject with image mask.public PdfImageXObject(PdfStream pdfStream)
PdfImageXObject instance by PdfStream.
Note, this constructor doesn't perform any additional checkspdfStream - PdfStream with Image XObject.PdfXObject.makeXObject(PdfStream)public float getWidth()
Width key.getWidth in class PdfXObjectpublic float getHeight()
Height key.getHeight in class PdfXObjectpublic boolean isMask()
A mask can hide parts of an image by making those parts fully transparent.
public boolean isSoftMask()
A soft mask sets the transparency for an image.
public void flush()
PdfObject behind this wrapper, you have to ensure
that this object is added to the document, i.e. it has an indirect reference.
Basically this means that before flushing you need to explicitly call PdfObjectWrapper.makeIndirect(PdfDocument).
For example: wrapperInstance.makeIndirect(document).flush();
Note, that not every wrapper require this, only those that have such warning in documentation.flush in class PdfObjectWrapper<PdfStream>public PdfImageXObject copyTo(PdfDocument document)
document - target documentPdfImageXObject.public BufferedImage getBufferedImage() throws IOException
BufferedImage image.IOException - if an error occurs during reading.public byte[] getImageBytes()
public byte[] getImageBytes(boolean decoded)
PdfName.DCTDecode, PdfName.JBIG2Decode and PdfName.JPXDecode
filters will be ignored.decoded - if true, decodes stream bytes.public byte[] getImageBytes(PdfImageXObject.ImageBytesRetrievalProperties properties)
PdfName.DCTDecode, PdfName.JBIG2Decode and PdfName.JPXDecode
filters will be ignored.properties - an instance of PdfImageXObject.ImageBytesRetrievalProperties to configure the options.public ImageType identifyImageType()
PdfImageXObject.
Note that this has nothing to do with the original type of the image. For instance, the return value
of this method will never be ImageType.PNG as we lose this information when converting a
PNG image into something that can be put into a PDF file.
The possible values are: ImageType.JPEG, ImageType.JPEG2000, ImageType.JBIG2,
ImageType.TIFF, ImageType.PNGpublic ImageType identifyImageType(PdfImageXObject.ImageBytesRetrievalProperties properties)
PdfImageXObject.
Note that this has nothing to do with the original type of the image. For instance, the return value
of this method will never be ImageType.PNG as we lose this information when converting a
PNG image into something that can be put into a PDF file.
The possible values are: ImageType.JPEG, ImageType.JPEG2000, ImageType.JBIG2,
ImageType.TIFF, ImageType.PNGproperties - an instance of PdfImageXObject.ImageBytesRetrievalProperties to configure the options,
these options can influence the typepublic String identifyImageFileExtension()
PdfImageXObject.
Possible values are: 'png', 'jpg', 'jp2', 'tif', 'jbig2'.
This extension can later be used together with the result of getImageBytes().String with recommended file extensionidentifyImageType(ImageBytesRetrievalProperties)public String identifyImageFileExtension(PdfImageXObject.ImageBytesRetrievalProperties properties)
PdfImageXObject.
Possible values are: 'png', 'jpg', 'jp2', 'tif', 'jbig2'.
This extension can later be used together with the result of getImageBytes().properties - an instance of PdfImageXObject.ImageBytesRetrievalProperties to configure the options,
* these options can influence the file extensionString with recommended file extensionpublic PdfImageXObject put(PdfName key, PdfObject value)
key - key to insert or to overridevalue - the value to associate with the specified keyCopyright © 1998–2025 Apryse Group NV. All rights reserved.