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
public class ImageRenderInfo extends AbstractRenderInfo
Represents image data from a PDF.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<CanvasTag>
canvasTagHierarchy
Hierarchy of nested canvas tags for the text from the most inner (nearest to text) tag to the most outer.private PdfDictionary
colorSpaceDictionary
The color space dictionary from resources which are associated with the image.private Matrix
ctm
The coordinate transformation matrix that was in effect when the image was rendered.private PdfImageXObject
image
private boolean
isInline
Defines if the encountered image was inline.private PdfName
resourceName
-
Fields inherited from class com.itextpdf.kernel.pdf.canvas.parser.data.AbstractRenderInfo
gs
-
-
Constructor Summary
Constructors Constructor Description ImageRenderInfo(java.util.Stack<CanvasTag> canvasTagHierarchy, CanvasGraphicsState gs, Matrix ctm, PdfStream imageStream, PdfName resourceName, PdfDictionary colorSpaceDictionary, boolean isInline)
Creates an ImageRenderInfo.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description float
getArea()
Gets the size of the image in User space units.java.util.List<CanvasTag>
getCanvasTagHierarchy()
Gets hierarchy of the canvas tags that wraps given text.PdfDictionary
getColorSpaceDictionary()
Gets the color space dictionary of the image.PdfImageXObject
getImage()
Gets the image wrapped in ImageXObject.Matrix
getImageCtm()
Gets the coordinate transformation matrix in User space which was active when this image was rendered.PdfName
getImageResourceName()
Gets the name of the image resource.int
getMcid()
Gets the marked-content identifier associated with thisImageRenderInfo
instance.Vector
getStartPoint()
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
-
-
-
-
Field Detail
-
ctm
private final Matrix ctm
The coordinate transformation matrix that was in effect when the image was rendered.
-
image
private final PdfImageXObject image
-
colorSpaceDictionary
private final PdfDictionary colorSpaceDictionary
The color space dictionary from resources which are associated with the image.
-
isInline
private final boolean isInline
Defines if the encountered image was inline.
-
resourceName
private final PdfName resourceName
-
canvasTagHierarchy
private final java.util.List<CanvasTag> canvasTagHierarchy
Hierarchy of nested canvas tags for the text from the most inner (nearest to text) tag to the most outer.
-
-
Constructor Detail
-
ImageRenderInfo
public ImageRenderInfo(java.util.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 outergs
- thecanvas graphics state
ctm
- the coordinate transformation matrix at the time the image is renderedimageStream
- the image stream objectresourceName
- thename
of the image resourcecolorSpaceDictionary
- the color space dictionary from resources which are associated with the imageisInline
- defines if the encountered image was inline
-
-
Method Detail
-
getImage
public PdfImageXObject 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
public PdfName getImageResourceName()
Gets the name of the image resource.- Returns:
- the
name
of the image resource
-
getStartPoint
public Vector 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
public Matrix 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
public PdfDictionary getColorSpaceDictionary()
Gets the color space dictionary of the image.- Returns:
- the color space dictionary from resources which are associated with the image
-
getCanvasTagHierarchy
public java.util.List<CanvasTag> 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 idcheckTheTopmostLevelOnly
- indicates whether to check the topmost level of marked content stack only- Returns:
true
if thisImageRenderInfo
instance is marked with this id,false
otherwise
-
-