Class TextRenderInfo
java.lang.Object
com.itextpdf.kernel.pdf.canvas.parser.data.AbstractRenderInfo
com.itextpdf.kernel.pdf.canvas.parser.data.TextRenderInfo
- All Implemented Interfaces:
-
IEventData
Provides information and calculations needed by render listeners to display/evaluate text render operations.
This is passed between the
This is passed between the
PdfCanvasProcessor
and IEventListener
objects as text rendering operations are discovered
-
Field Summary
Fields inherited from class com.itextpdf.kernel.pdf.canvas.parser.data.AbstractRenderInfo
gs
-
Constructor Summary
ConstructorDescriptionTextRenderInfo
(PdfString str, CanvasGraphicsState gs, Matrix textMatrix, Stack<CanvasTag> canvasTagHierarchy) Creates a new TextRenderInfo object -
Method Summary
Modifier and TypeMethodDescriptionGets /ActualText tag entry value if this text chunk is marked content.Gets the ascent line for the text (i.e.Gets the baseline for the text (i.e.Gets hierarchy of the canvas tags that wraps given text.Provides detail useful if a listener needs access to the position of each individual glyph in the text render operationfloat
Gets the descent line for the text (i.e.Gets /E tag (expansion text) entry value if this text chunk is marked content.getFont()
Getter for the fontfloat
float
float
int
getMcid()
Gets the marked-content identifier associated with thisTextRenderInfo
instancefloat
getRise()
The rise represents how far above the nominal baseline the text should be rendered.float
getText()
Gets the text to be rendered according to canvas operators.Gets original Text matrix.int
float
float
boolean
hasMcid
(int mcid) Checks if thisTextRenderInfo
instance belongs to a marked content sequence with a given mcid.boolean
hasMcid
(int mcid, boolean checkTheTopmostLevelOnly) Checks if thisTextRenderInfo
instance belongs to a marked content sequence with a given mcid.boolean
Determines if the text represented by thisTextRenderInfo
instance is written in a text showing operator wrapped by /ReversedChars marked content sequenceMethods inherited from class com.itextpdf.kernel.pdf.canvas.parser.data.AbstractRenderInfo
checkGraphicsState, getGraphicsState, isGraphicsStatePreserved, preserveGraphicsState, releaseGraphicsState
-
Constructor Details
-
TextRenderInfo
public TextRenderInfo(PdfString str, CanvasGraphicsState gs, Matrix textMatrix, Stack<CanvasTag> canvasTagHierarchy) Creates a new TextRenderInfo object- Parameters:
-
str
- the PDF string that should be displayed -
gs
- the graphics state (note: at this time, this is not immutable, so don't cache it) -
textMatrix
- the text matrix at the time of the render operation -
canvasTagHierarchy
- the marked content tags sequence, if available
-
-
Method Details
-
getText
Gets the text to be rendered according to canvas operators.- Returns:
- the text to render
-
getPdfString
- Returns:
- original PDF string
-
getTextMatrix
Gets original Text matrix.- Returns:
- text matrix.
-
hasMcid
public boolean hasMcid(int mcid) Checks if thisTextRenderInfo
instance belongs to a marked content sequence with a given mcid.- Parameters:
-
mcid
- a marked content id - Returns:
-
true
if thisTextRenderInfo
instance is marked with this id,false
otherwise
-
hasMcid
public boolean hasMcid(int mcid, boolean checkTheTopmostLevelOnly) Checks if thisTextRenderInfo
instance belongs to 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 thisTextRenderInfo
instance is marked with this id,false
otherwise
-
getMcid
public int getMcid()Gets the marked-content identifier associated with thisTextRenderInfo
instance- Returns:
- associated marked-content identifier or -1 in case content is unmarked
-
getBaseline
Gets the baseline for the text (i.e. the line that the text 'sits' on) This value includes the Rise of the draw operation - seegetRise()
for the amount added by Rise- Returns:
- the baseline line segment
-
getUnscaledBaseline
-
getAscentLine
Gets the ascent line for the text (i.e. the line that represents the topmost extent that a string of the current font could have). This value includes the Rise of the draw operation - seegetRise()
for the amount added by Rise.- Returns:
- a LineSegment instance
-
getDescentLine
Gets the descent line for the text (i.e. the line that represents the bottom most extent that a string of the current font could have). This value includes the Rise of the draw operation - seegetRise()
for the amount added by Rise.- Returns:
- a LineSegment instance
-
getFont
Getter for the font- Returns:
- the font
-
getRise
public float getRise()The rise represents how far above the nominal baseline the text should be rendered. ThegetBaseline()
,getAscentLine()
andgetDescentLine()
methods already include Rise. This method is exposed to allow listeners to determine if an explicit rise was involved in the computation of the baseline (this might be useful, for example, for identifying superscript rendering)- Returns:
- The Rise for the text draw operation, in user space units (Ts value, scaled to user space)
-
getCharacterRenderInfos
Provides detail useful if a listener needs access to the position of each individual glyph in the text render operation- Returns:
-
A list of
TextRenderInfo
objects that represent each glyph used in the draw operation. The next effect is if there was a separate Tj opertion for each character in the rendered string
-
getSingleSpaceWidth
public float getSingleSpaceWidth()- Returns:
- The width, in user space units, of a single space character in the current font
-
getTextRenderMode
public int getTextRenderMode()- Returns:
-
the text render mode that should be used for the text. From the PDF specification, this means:
- 0 = Fill text
- 1 = Stroke text
- 2 = Fill, then stroke text
- 3 = Invisible
- 4 = Fill text and add to path for clipping
- 5 = Stroke text and add to path for clipping
- 6 = Fill, then stroke text and add to path for clipping
- 7 = Add text to padd for clipping
-
getFillColor
- Returns:
- the current fill color.
-
getStrokeColor
- Returns:
- the current stroke color.
-
getFontSize
public float getFontSize() -
getHorizontalScaling
public float getHorizontalScaling() -
getCharSpacing
public float getCharSpacing() -
getWordSpacing
public float getWordSpacing() -
getLeading
public float getLeading() -
getActualText
Gets /ActualText tag entry value if this text chunk is marked content.- Returns:
-
/ActualText value or
null
if none found
-
getExpansionText
Gets /E tag (expansion text) entry value if this text chunk is marked content.- Returns:
-
/E value or
null
if none found
-
isReversedChars
public boolean isReversedChars()Determines if the text represented by thisTextRenderInfo
instance is written in a text showing operator wrapped by /ReversedChars marked content sequence- Returns:
-
true
if this text block lies within /ReversedChars block,false
otherwise
-
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).
-
getUnscaledWidth
public float getUnscaledWidth()- Returns:
- the unscaled (i.e. in Text space) width of the text
-