Table of Contents

Interface IRenderer

Namespace
iText.Layout.Renderer
Assembly
itext.layout.dll

A renderer object is responsible for drawing a corresponding layout object on a document or canvas.

public interface IRenderer : IPropertyContainer
Inherited Members

Remarks

A renderer object is responsible for drawing a corresponding layout object on a document or canvas. Every layout object has a renderer, by default one of the corresponding type, e.g. you can ask an Image for its ImageRenderer. Renderers are designed to be extensible, and custom implementations can be seeded to layout objects (or their custom subclasses) at runtime.

Methods

AddChild(IRenderer)

Adds a child to the current renderer

void AddChild(IRenderer renderer)

Parameters

renderer IRenderer

a child to be added

Draw(DrawContext)

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

void Draw(DrawContext drawContext)

Parameters

drawContext DrawContext

contains the PdfDocument to which the renderer subtree if flushed, the PdfCanvas on which the renderer subtree is drawn and other additional parameters needed to perform drawing

GetChildRenderers()

Gets the child IRenderer s.

IList<IRenderer> GetChildRenderers()

Returns

IList<IRenderer>

a list of direct child renderers of this instance

GetModelElement()

Gets the model element associated with this renderer.

IPropertyContainer GetModelElement()

Returns

IPropertyContainer

the model element, as a container of properties

GetNextRenderer()

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

IRenderer GetNextRenderer()

Returns

IRenderer

new renderer instance

GetOccupiedArea()

Gets the resultant occupied area after the last call to the Layout(LayoutContext) method.

LayoutArea GetOccupiedArea()

Returns

LayoutArea

LayoutArea instance

GetParent()

Gets the parent IRenderer.

IRenderer GetParent()

Returns

IRenderer

direct parent renderer of this instance

GetProperty<T1>(int, T1)

Gets a property from this entity or one of its hierarchical parents.

T1 GetProperty<T1>(int property, T1 defaultValue)

Parameters

property int

the property to be retrieved

defaultValue T1

a fallback value

Returns

T1

the value of the given property

Type Parameters

T1

the return type associated with the property

Remarks

Gets a property from this entity or one of its hierarchical parents. If the property is not found, defaultValue will be returned.

IsFlushed()

Indicates whether this renderer is flushed or not, i.e. if Draw(DrawContext) has already been called.

bool IsFlushed()

Returns

bool

whether the renderer has been flushed

Layout(LayoutContext)

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

LayoutResult Layout(LayoutContext layoutContext)

Parameters

layoutContext LayoutContext

the description of layout area and any other additional information

Returns

LayoutResult

result of the layout process

Remarks

This method simulates positioning of the renderer, including all of its children, and returns the LayoutResult , representing the layout result, including occupied area, status, i.e. if there was enough place to fit the renderer subtree, etc. LayoutResult can be extended to return custom layout results for custom elements, e.g. TextRenderer uses 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.

Move(float, float)

Moves the renderer subtree by the specified offset.

void Move(float dx, float dy)

Parameters

dx float

the x-axis offset in points. Positive value will move the renderer subtree to the right.

dy float

the y-axis offset in points. Positive value will move the renderer subtree to the top.

Remarks

Moves the renderer subtree by the specified offset. This method affects occupied area of the renderer.

SetParent(IRenderer)

Explicitly sets this object as the child of another IRenderer in the renderer hierarchy.

IRenderer SetParent(IRenderer parent)

Parameters

parent IRenderer

the object to place higher in the renderer hierarchy

Returns

IRenderer

by default, this object

Remarks

Explicitly sets this object as the child of another IRenderer in the renderer hierarchy. Some implementations also use this method internally to create a consistent hierarchy tree.