iText 7 7.1.9 API
iText.Layout.Renderer.TextRenderer Class Reference

This class represents the renderer object for a iText.Layout.Element.Text object. More...

Inheritance diagram for iText.Layout.Renderer.TextRenderer:
iText.Layout.Renderer.AbstractRenderer iText.Layout.Renderer.ILeafElementRenderer iText.Layout.Renderer.IRenderer iText.Layout.Renderer.IRenderer iText.Layout.IPropertyContainer iText.Layout.IPropertyContainer iText.Layout.Renderer.LinkRenderer

Public Member Functions

  TextRenderer (Text textElement)
  Creates a TextRenderer from its corresponding layout object. More...
 
  TextRenderer (Text textElement, String text)
  Creates a TextRenderer from its corresponding layout object, with a custom text to replace the contents of the iText.Layout.Element.Text. More...
 
override LayoutResult  Layout (LayoutContext layoutContext)
  This method simulates positioning of the renderer, including all of its children, and returns the iText.Layout.Layout.LayoutResult , representing the layout result, including occupied area, status, i.e. if there was enough place to fit the renderer subtree, etc. More...
 
virtual void  ApplyOtf ()
 
override void  Draw (DrawContext drawContext)
  Flushes the renderer subtree contents, i.e. draws itself on canvas, adds necessary objects to the iText.Kernel.Pdf.PdfDocument etc. More...
 
override void  DrawBackground (DrawContext drawContext)
  Draws a background layer if it is defined by a key iText.Layout.Properties.Property.BACKGROUND in either the layout element or this IRenderer itself. More...
 
virtual void  TrimFirst ()
  Trims any whitespace characters from the start of the iText.IO.Font.Otf.GlyphLine to be rendered. More...
 
virtual float  GetAscent ()
  Gets the maximum offset above the base line that this Text extends to. More...
 
virtual float  GetDescent ()
  Gets the maximum offset below the base line that this Text extends to. More...
 
virtual float  GetYLine ()
  Gets the position on the canvas of the imaginary horizontal line upon which the iText.Layout.Element.Text 's contents will be written. More...
 
virtual void  MoveYLineTo (float y)
  Moves the vertical position to the parameter's value. More...
 
virtual void  SetText (String text)
  Manually sets the contents of the Text's representation on the canvas, regardless of the Text's own contents. More...
 
virtual void  SetText (GlyphLine text, int leftPos, int rightPos)
  Manually sets a GlyphLine to be rendered with a specific start and end point. More...
 
virtual GlyphLine  GetText ()
 
virtual int  Length ()
  The length of the whole text assigned to this renderer. More...
 
override String  ToString ()
 
virtual int  CharAt (int pos)
  Gets char code at given position for the text belonging to this renderer. More...
 
virtual float  GetTabAnchorCharacterPosition ()
 
override IRenderer  GetNextRenderer ()
  Gets a new instance of this class to be used as a next renderer, after this renderer is used, if Layout(iText.Layout.Layout.LayoutContext) is called more than once. More...
 
override MinMaxWidth  GetMinMaxWidth ()
 
- Public Member Functions inherited from iText.Layout.Renderer.AbstractRenderer
virtual void  AddChild (IRenderer renderer)
  Adds a child to the current renderer More...
 
virtual IPropertyContainer  GetModelElement ()
  Gets the model element associated with this renderer. More...
 
virtual IList< IRenderer GetChildRenderers ()
  Gets the child IRenderer s. More...
 
virtual bool  HasProperty (int property)
  Checks if this entity has the specified property. More...
 
virtual bool  HasOwnProperty (int property)
  Checks if this entity has the specified property, i.e. if it was set to this very element earlier More...
 
virtual bool  HasOwnOrModelProperty (int property)
  Checks if this renderer or its model element have the specified property, i.e. if it was set to this very element or its very model element earlier. More...
 
virtual void  DeleteOwnProperty (int property)
  Deletes the own property of this entity. More...
 
virtual void  DeleteProperty (int property)
  Deletes property from this very renderer, or in case the property is specified on its model element, the property of the model element is deleted More...
 
virtual T1  GetProperty< T1 > (int key)
  Gets the property from this entity. More...
 
virtual T1  GetOwnProperty< T1 > (int property)
  Gets own property from this entity. More...
 
virtual T1  GetProperty< T1 > (int property, T1 defaultValue)
  Gets a property from this entity or one of its hierarchical parents. More...
 
virtual void  SetProperty (int property, Object value)
  Sets a property for this entity. More...
 
virtual T1  GetDefaultProperty< T1 > (int property)
  Gets the default property from this entity. More...
 
virtual PdfFont  GetPropertyAsFont (int property)
  Returns a property with a certain key, as a font object. More...
 
virtual Color  GetPropertyAsColor (int property)
  Returns a property with a certain key, as a color. More...
 
virtual TransparentColor  GetPropertyAsTransparentColor (int property)
  Returns a property with a certain key, as a iText.Layout.Properties.TransparentColor. More...
 
virtual ? float  GetPropertyAsFloat (int property)
  Returns a property with a certain key, as a floating point value. More...
 
virtual ? float  GetPropertyAsFloat (int property, float? defaultValue)
  Returns a property with a certain key, as a floating point value. More...
 
virtual ? bool  GetPropertyAsBoolean (int property)
  Returns a property with a certain key, as a boolean value. More...
 
virtual UnitValue  GetPropertyAsUnitValue (int property)
  Returns a property with a certain key, as a unit value. More...
 
virtual ? int  GetPropertyAsInteger (int property)
  Returns a property with a certain key, as an integer value. More...
 
override String  ToString ()
  Returns a string representation of the renderer. More...
 
virtual LayoutArea  GetOccupiedArea ()
  Gets the resultant occupied area after the last call to the Layout(iText.Layout.Layout.LayoutContext) method. More...
 
virtual void  DrawChildren (DrawContext drawContext)
  Performs the drawing operation for all children of this renderer. More...
 
virtual void  DrawBorder (DrawContext drawContext)
  Performs the drawing operation for the border of this renderer, if defined by any of the iText.Layout.Properties.Property.BORDER values in either the layout element or this IRenderer itself. More...
 
virtual bool  IsFlushed ()
  Indicates whether this renderer is flushed or not, i.e. if Draw(DrawContext) has already been called. More...
 
virtual IRenderer  SetParent (IRenderer parent)
  Explicitly sets this object as the child of another IRenderer in the renderer hierarchy. More...
 
virtual IRenderer  GetParent ()
  Gets the parent IRenderer. More...
 
virtual void  Move (float dxRight, float dyUp)
  Moves the renderer subtree by the specified offset. More...
 
virtual IList< Rectangle InitElementAreas (LayoutArea area)
  Gets all rectangles that this IRenderer can draw upon in the given area. More...
 
virtual Rectangle  GetOccupiedAreaBBox ()
  Gets the bounding box that contains all content written to the DrawContext by this IRenderer. More...
 
virtual Rectangle  GetBorderAreaBBox ()
  Gets the border box of a renderer. More...
 
virtual Rectangle  GetInnerAreaBBox ()
 
virtual Rectangle  ApplyMargins (Rectangle rect, bool reverse)
  Applies margins of the renderer on the given rectangle More...
 
virtual Rectangle  ApplyBorderBox (Rectangle rect, bool reverse)
  Applies the border box of the renderer on the given rectangle If the border of a certain side is null, the side will remain as it was. More...
 
virtual Rectangle  ApplyPaddings (Rectangle rect, bool reverse)
  Applies paddings of the renderer on the given rectangle More...
 
virtual bool  IsFirstOnRootArea ()
 

Detailed Description

This class represents the renderer object for a iText.Layout.Element.Text object.

This class represents the renderer object for a iText.Layout.Element.Text object. It will draw the glyphs of the textual content on the DrawContext.

Constructor & Destructor Documentation

◆ TextRenderer() [1/2]

iText.Layout.Renderer.TextRenderer.TextRenderer ( Text  textElement )
inline

Creates a TextRenderer from its corresponding layout object.

Parameters
textElement the iText.Layout.Element.Text which this object should manage

◆ TextRenderer() [2/2]

iText.Layout.Renderer.TextRenderer.TextRenderer ( Text  textElement,
String  text 
)
inline

Creates a TextRenderer from its corresponding layout object, with a custom text to replace the contents of the iText.Layout.Element.Text.

Parameters
textElement the iText.Layout.Element.Text which this object should manage
text the replacement text

Member Function Documentation

◆ CharAt()

virtual int iText.Layout.Renderer.TextRenderer.CharAt ( int  pos )
inlinevirtual

Gets char code at given position for the text belonging to this renderer.

Parameters
pos the position in range [0; length())
Returns
Unicode char code

◆ Draw()

override void iText.Layout.Renderer.TextRenderer.Draw ( DrawContext  drawContext )
inlinevirtual

Flushes the renderer subtree contents, i.e. draws itself on canvas, adds necessary objects to the iText.Kernel.Pdf.PdfDocument etc.

Reimplemented from iText.Layout.Renderer.AbstractRenderer.

◆ DrawBackground()

override void iText.Layout.Renderer.TextRenderer.DrawBackground ( DrawContext  drawContext )
inlinevirtual

Draws a background layer if it is defined by a key iText.Layout.Properties.Property.BACKGROUND in either the layout element or this IRenderer itself.

Parameters
drawContext the context (canvas, document, etc) of this drawing operation.

Reimplemented from iText.Layout.Renderer.AbstractRenderer.

◆ GetAscent()

virtual float iText.Layout.Renderer.TextRenderer.GetAscent ( )
inlinevirtual

Gets the maximum offset above the base line that this Text extends to.

Returns
the upwards vertical offset of this iText.Layout.Element.Text

Implements iText.Layout.Renderer.ILeafElementRenderer.

◆ GetDescent()

virtual float iText.Layout.Renderer.TextRenderer.GetDescent ( )
inlinevirtual

Gets the maximum offset below the base line that this Text extends to.

Returns
the downwards vertical offset of this iText.Layout.Element.Text

Implements iText.Layout.Renderer.ILeafElementRenderer.

◆ GetNextRenderer()

override IRenderer iText.Layout.Renderer.TextRenderer.GetNextRenderer ( )
inlinevirtual

Gets a new instance of this class to be used as a next renderer, after this renderer is used, if Layout(iText.Layout.Layout.LayoutContext) is called more than once.

Returns
new renderer instance

Implements iText.Layout.Renderer.AbstractRenderer.

◆ GetYLine()

virtual float iText.Layout.Renderer.TextRenderer.GetYLine ( )
inlinevirtual

Gets the position on the canvas of the imaginary horizontal line upon which the iText.Layout.Element.Text 's contents will be written.

Returns
the y position of this text on the DrawContext

◆ Layout()

override LayoutResult iText.Layout.Renderer.TextRenderer.Layout ( LayoutContext  layoutContext )
inlinevirtual

This method simulates positioning of the renderer, including all of its children, and returns the iText.Layout.Layout.LayoutResult , representing the layout result, including occupied area, status, i.e. if there was enough place to fit the renderer subtree, etc.

This method simulates positioning of the renderer, including all of its children, and returns the iText.Layout.Layout.LayoutResult , representing the layout result, including occupied area, status, i.e. if there was enough place to fit the renderer subtree, etc. iText.Layout.Layout.LayoutResult can be extended to return custom layout results for custom elements, e.g. TextRenderer uses iText.Layout.Layout.TextLayoutResult as its result. This method can be called standalone to learn how much area the renderer subtree needs, or can be called before Draw(DrawContext) , to prepare the renderer to be flushed to the output stream.

Parameters
layoutContext the description of layout area and any other additional information
Returns
result of the layout process

Implements iText.Layout.Renderer.AbstractRenderer.

◆ Length()

virtual int iText.Layout.Renderer.TextRenderer.Length ( )
inlinevirtual

The length of the whole text assigned to this renderer.

Returns
the text length

◆ MoveYLineTo()

virtual void iText.Layout.Renderer.TextRenderer.MoveYLineTo ( float  y )
inlinevirtual

Moves the vertical position to the parameter's value.

Parameters
y the new vertical position of the Text

◆ SetText() [1/2]

virtual void iText.Layout.Renderer.TextRenderer.SetText ( GlyphLine  text,
int  leftPos,
int  rightPos 
)
inlinevirtual

Manually sets a GlyphLine to be rendered with a specific start and end point.

Parameters
text a iText.IO.Font.Otf.GlyphLine
leftPos the leftmost end of the GlyphLine
rightPos the rightmost end of the GlyphLine

◆ SetText() [2/2]

virtual void iText.Layout.Renderer.TextRenderer.SetText ( String  text )
inlinevirtual

Manually sets the contents of the Text's representation on the canvas, regardless of the Text's own contents.

Parameters
text the replacement text

◆ TrimFirst()

virtual void iText.Layout.Renderer.TextRenderer.TrimFirst ( )
inlinevirtual

Trims any whitespace characters from the start of the iText.IO.Font.Otf.GlyphLine to be rendered.