public class PdfImageXObject extends PdfXObject
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.
|
protected static PdfStream |
createPdfStream(ImageData image, PdfImageXObject imageMask)
Deprecated.
|
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.
|
float |
getWidth()
Gets width of image, Width key.
|
String |
identifyImageFileExtension()
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 .
|
PdfImageXObject |
put(PdfName key, PdfObject value)
Puts the value into Image XObject dictionary and associates it with the specified key.
|
isWrappedObjectMustBeIndirect, makeXObject, setLayer
ensureObjectIsAddedToDocument, ensureUnderlyingObjectHasIndirectReference, getPdfObject, isFlushed, makeIndirect, makeIndirect, markObjectAsIndirect, setForbidRelease, setModified, setPdfObject, unsetForbidRelease
public 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 checks
pdfStream
- PdfStream
with Image XObject.
PdfXObject.makeXObject(PdfStream)
public float getWidth()
Width
key.
getWidth
in class PdfXObject
public float getHeight()
Height
key.
getHeight
in class PdfXObject
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 document
PdfImageXObject
.
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 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 loose 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.PNG
public 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 extension
identifyImageType()
public PdfImageXObject put(PdfName key, PdfObject value)
key
- key to insert or to override
value
- the value to associate with the specified key
@Deprecated protected static PdfStream createPdfStream(ImageData image, PdfImageXObject imageMask)
Copyright © 1998–2017 iText Group NV. All rights reserved.