Class ImageRenderInfo
java.lang.Object
com.itextpdf.kernel.pdf.canvas.parser.data.AbstractRenderInfo
com.itextpdf.kernel.pdf.canvas.parser.data.ImageRenderInfo
- All Implemented Interfaces:
-
IEventData
Represents image data from a PDF.
-
Field Summary
Fields inherited from class com.itextpdf.kernel.pdf.canvas.parser.data.AbstractRenderInfo
gs
-
Constructor Summary
ConstructorDescriptionImageRenderInfo
(Stack<CanvasTag> canvasTagHierarchy, CanvasGraphicsState gs, Matrix ctm, PdfStream imageStream, PdfName resourceName, PdfDictionary colorSpaceDictionary, boolean isInline) Creates an ImageRenderInfo. -
Method Summary
Modifier and TypeMethodDescriptionfloat
getArea()
Gets the size of the image in User space units.Gets hierarchy of the canvas tags that wraps given text.Gets the color space dictionary of the image.getImage()
Gets the image wrapped in ImageXObject.Gets the coordinate transformation matrix in User space which was active when this image was rendered.Gets the name of the image resource.int
getMcid()
Gets the marked-content identifier associated with thisImageRenderInfo
instance.Gets the vector in User space representing the start point of the image.boolean
hasMcid
(int mcid) Checks if thisImageRenderInfo
instance is associated with a marked content sequence with a given mcid.boolean
hasMcid
(int mcid, boolean checkTheTopmostLevelOnly) Checks if thisImageRenderInfo
instance is associated with a marked content sequence with a given mcid.boolean
isInline()
Gets the inline flag.Methods inherited from class com.itextpdf.kernel.pdf.canvas.parser.data.AbstractRenderInfo
checkGraphicsState, getGraphicsState, isGraphicsStatePreserved, preserveGraphicsState, releaseGraphicsState
-
Constructor Details
-
ImageRenderInfo
public ImageRenderInfo(Stack<CanvasTag> canvasTagHierarchy, CanvasGraphicsState gs, Matrix ctm, PdfStream imageStream, PdfName resourceName, PdfDictionary colorSpaceDictionary, boolean isInline) Creates an ImageRenderInfo.- Parameters:
-
canvasTagHierarchy
- the hierarchy of nested canvas tags for the text from the most inner (nearest to text) tag to the most outer -
gs
- thecanvas graphics state
-
ctm
- the coordinate transformation matrix at the time the image is rendered -
imageStream
- the image stream object -
resourceName
- thename
of the image resource -
colorSpaceDictionary
- the color space dictionary from resources which are associated with the image -
isInline
- defines if the encountered image was inline
-
-
Method Details
-
getImage
Gets the image wrapped in ImageXObject. You can:- get image bytes with
PdfImageXObject.getImageBytes(boolean)
, these image bytes represent native image, i.e you can write these bytes to disk and get just an usual image; - obtain PdfStream object which contains image dictionary with
PdfObjectWrapper.getPdfObject()
method; - convert image to
BufferedImage
withPdfImageXObject.getBufferedImage()
; // Android-Conversion-Skip-Line (java.awt library isn't available on Android)
- Returns:
-
the
image
- get image bytes with
-
getImageResourceName
Gets the name of the image resource.- Returns:
-
the
name
of the image resource
-
getStartPoint
Gets the vector in User space representing the start point of the image.- Returns:
-
the
vector
in User space representing the start point of the image
-
getImageCtm
Gets the coordinate transformation matrix in User space which was active when this image was rendered.- Returns:
- the coordinate transformation matrix in User space which was active when this image was rendered
-
getArea
public float getArea()Gets the size of the image in User space units.- Returns:
- the size of the image, in User space units
-
isInline
public boolean isInline()Gets the inline flag.- Returns:
-
true
if image was inlined in original stream
-
getColorSpaceDictionary
Gets the color space dictionary of the image.- Returns:
- the color space dictionary from resources which are associated with the image
-
getCanvasTagHierarchy
Gets hierarchy of the canvas tags that wraps given text.- Returns:
- list of the wrapping canvas tags. The first tag is the innermost (nearest to the text).
-
getMcid
public int getMcid()Gets the marked-content identifier associated with thisImageRenderInfo
instance.- Returns:
- associated marked-content identifier or -1 in case content is unmarked
-
hasMcid
public boolean hasMcid(int mcid) Checks if thisImageRenderInfo
instance is associated with a marked content sequence with a given mcid.- Parameters:
-
mcid
- a marked content id - Returns:
-
true
if the image is marked with this id,false
otherwise
-
hasMcid
public boolean hasMcid(int mcid, boolean checkTheTopmostLevelOnly) Checks if thisImageRenderInfo
instance is associated with a marked content sequence with a given mcid.- Parameters:
-
mcid
- a marked content id -
checkTheTopmostLevelOnly
- indicates whether to check the topmost level of marked content stack only - Returns:
-
true
if thisImageRenderInfo
instance is marked with this id,false
otherwise
-