Table of Contents

Class TextHandler

Namespace
iTextSharp.text.xml
Assembly
iTextSharp.LGPLv2.Core.dll

The iTextHandler -class maps several XHTML-tags to iText-objects.

public class TextHandler : ParserBase
Inheritance
TextHandler
Derived
Inherited Members

Constructors

TextHandler(IDocListener)

Constructs a new iTextHandler that will translate all the events triggered by the parser to actions on the Document -object.

public TextHandler(IDocListener document)

Parameters

document IDocListener

this is the document on which events must be triggered

TextHandler(IDocListener, NullValueDictionary<string, XmlPeer>)

@throws DocumentException @throws IOException

public TextHandler(IDocListener document, NullValueDictionary<string, XmlPeer> myTags)

Parameters

document IDocListener
myTags NullValueDictionary<string, XmlPeer>

TextHandler(IDocListener, TagMap)

@throws DocumentException @throws IOException

public TextHandler(IDocListener document, TagMap myTags)

Parameters

document IDocListener
myTags TagMap

TextHandler(IDocListener, TagMap, BaseFont)

@throws DocumentException @throws IOException

public TextHandler(IDocListener document, TagMap myTags, BaseFont bf)

Parameters

document IDocListener
myTags TagMap
bf BaseFont

Fields

Chapters

Counts the number of chapters in this document.

protected int Chapters

Field Value

int

ControlOpenClose

This is a flag that can be set, if you want to open and close the Document-object yourself.

protected bool ControlOpenClose

Field Value

bool

CurrentChunk

This is the current chunk to which characters can be added.

protected Chunk CurrentChunk

Field Value

Chunk

Document

This is the resulting document.

protected IDocListener Document

Field Value

IDocListener

Ignore

This is the current chunk to which characters can be added.

protected bool Ignore

Field Value

bool

MyTags

protected NullValueDictionary<string, XmlPeer> MyTags

Field Value

NullValueDictionary<string, XmlPeer>

Stack

This is a Stack of objects, waiting to be added to the document.

protected Stack<IElement> Stack

Field Value

Stack<IElement>

Properties

DefaultFont

public BaseFont DefaultFont { get; set; }

Property Value

BaseFont

Methods

AddImage(Image)

protected void AddImage(Image img)

Parameters

img Image

Characters(string, int, int)

This method gets called when characters are encountered.

public override void Characters(string content, int start, int length)

Parameters

content string

an array of characters

start int

the start position in the array

length int

the number of characters to read from the array

EndElement(string, string, string)

This method gets called when an end tag is encountered.

public override void EndElement(string uri, string lname, string name)

Parameters

uri string
lname string
name string

the name of the tag that ends

HandleEndingTags(string)

This method deals with the starting tags.

public void HandleEndingTags(string name)

Parameters

name string

the name of the tag

HandleStartingTags(string, Properties)

This method deals with the starting tags.

public void HandleStartingTags(string name, Properties attributes)

Parameters

name string

the name of the tag

attributes Properties

the list of attributes

IgnorableWhitespace(char[], int, int)

This method gets called when ignorable white space encountered.

public static void IgnorableWhitespace(char[] ch, int start, int length)

Parameters

ch char[]

an array of characters

start int

the start position in the array

length int

the number of characters to read from the array

IsDocumentRoot(string)

Checks if a certain tag corresponds with the roottag.

protected static bool IsDocumentRoot(string tag)

Parameters

tag string

a presumed tagname

Returns

bool

true if tag equals itext , false otherwise.

SetControlOpenClose(bool)

Sets the parameter that allows you to enable/disable the control over the Document.Open() and Document.Close() method.

public void SetControlOpenClose(bool controlOpenClose)

Parameters

controlOpenClose bool

set this to false if you plan to open/close the Document yourself

Remarks

If you set this parameter to true (= default), the parser will open the Document object when the start-root-tag is encountered and close it when the end-root-tag is met. If you set it to false, you have to open and close the Document object yourself.

StartElement(string, string, string, INullValueDictionary<string, string>)

This method gets called when a start tag is encountered.

public override void StartElement(string uri, string lname, string name, INullValueDictionary<string, string> attrs)

Parameters

uri string
lname string
name string

the name of the tag that is encountered

attrs INullValueDictionary<string, string>

the list of attributes