com.lowagie.text.xml

Class SAXiTextHandler

public class SAXiTextHandler extends DefaultHandler

This class is a Handler that controls the iText XML to PDF conversion. Subclass it, if you want to change the way iText translates XML to PDF.
Field Summary
BaseFontbf
floatbottomMargin
current margin of a page.
protected intchapters
Counts the number of chapters in this document.
protected booleancontrolOpenClose
This is a flag that can be set, if you want to open and close the Document-object yourself.
protected ChunkcurrentChunk
This is the current chunk to which characters can be added.
protected DocListenerdocument
This is the resulting document.
protected booleanignore
This is the current chunk to which characters can be added.
floatleftMargin
current margin of a page.
protected HashMapmyTags
This hashmap contains all the custom keys and peers.
floatrightMargin
current margin of a page.
protected Stackstack
This is a Stack of objects, waiting to be added to the document.
floattopMargin
current margin of a page.
Constructor Summary
SAXiTextHandler(DocListener document)
SAXiTextHandler(DocListener document, HtmlTagMap myTags)
SAXiTextHandler(DocListener document, HtmlTagMap myTags, BaseFont bf)
SAXiTextHandler(DocListener document, HashMap myTags)
Method Summary
protected voidaddImage(Image img)
voidcharacters(char[] ch, int start, int length)
This method gets called when characters are encountered.
voidendElement(String uri, String lname, String name)
This method gets called when an end tag is encountered.
voidhandleEndingTags(String name)
This method deals with the starting tags.
voidhandleStartingTags(String name, Properties attributes)
This method deals with the starting tags.
voidignorableWhitespace(char[] ch, int start, int length)
This method gets called when ignorable white space encountered.
protected booleanisDocumentRoot(String tag)
Checks if a certain tag corresponds with the roottag.
booleanisNewline(String tag)
Checks if a certain tag corresponds with the newpage-tag.
booleanisNewpage(String tag)
Checks if a certain tag corresponds with the newpage-tag.
voidsetBaseFont(BaseFont bf)
Sets the font that has to be used.
voidsetControlOpenClose(boolean controlOpenClose)
Sets the parameter that allows you to enable/disable the control over the Document.open() and Document.close() method.
voidstartElement(String uri, String lname, String name, Attributes attrs)
This method gets called when a start tag is encountered.

Field Detail

bf

private BaseFont bf

bottomMargin

float bottomMargin
current margin of a page.

chapters

protected int chapters
Counts the number of chapters in this document.

controlOpenClose

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

currentChunk

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

document

protected DocListener document
This is the resulting document.

ignore

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

leftMargin

float leftMargin
current margin of a page.

myTags

protected HashMap myTags
This hashmap contains all the custom keys and peers.

rightMargin

float rightMargin
current margin of a page.

stack

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

topMargin

float topMargin
current margin of a page.

Constructor Detail

SAXiTextHandler

public SAXiTextHandler(DocListener document)

Parameters: document

SAXiTextHandler

public SAXiTextHandler(DocListener document, HtmlTagMap myTags)

Parameters: document myTags

SAXiTextHandler

public SAXiTextHandler(DocListener document, HtmlTagMap myTags, BaseFont bf)

Parameters: document myTags bf

SAXiTextHandler

public SAXiTextHandler(DocListener document, HashMap myTags)

Parameters: document myTags

Method Detail

addImage

protected void addImage(Image img)

characters

public void characters(char[] ch, int start, int length)
This method gets called when characters are encountered.

Parameters: ch an array of characters start the start position in the array length the number of characters to read from the array

endElement

public void endElement(String uri, String lname, String name)
This method gets called when an end tag is encountered.

Parameters: uri the Uniform Resource Identifier lname the local name (without prefix), or the empty string if Namespace processing is not being performed. name the name of the tag that ends

handleEndingTags

public void handleEndingTags(String name)
This method deals with the starting tags.

Parameters: name the name of the tag

handleStartingTags

public void handleStartingTags(String name, Properties attributes)
This method deals with the starting tags.

Parameters: name the name of the tag attributes the list of attributes

ignorableWhitespace

public void ignorableWhitespace(char[] ch, int start, int length)
This method gets called when ignorable white space encountered.

Parameters: ch an array of characters start the start position in the array length the number of characters to read from the array

isDocumentRoot

protected boolean isDocumentRoot(String tag)
Checks if a certain tag corresponds with the roottag.

Parameters: tag a presumed tagname

Returns: true if tag equals itext ,false otherwise.

isNewline

private boolean isNewline(String tag)
Checks if a certain tag corresponds with the newpage-tag.

Parameters: tag a presumed tagname

Returns: true or false

isNewpage

private boolean isNewpage(String tag)
Checks if a certain tag corresponds with the newpage-tag.

Parameters: tag a presumed tagname

Returns: true or false

setBaseFont

public void setBaseFont(BaseFont bf)
Sets the font that has to be used.

Parameters: bf

setControlOpenClose

public void setControlOpenClose(boolean controlOpenClose)
Sets the parameter that allows you to enable/disable the control over the Document.open() and Document.close() method.

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.

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

startElement

public void startElement(String uri, String lname, String name, Attributes attrs)
This method gets called when a start tag is encountered.

Parameters: uri the Uniform Resource Identifier lname the local name (without prefix), or the empty string if Namespace processing is not being performed. name the name of the tag that is encountered attrs the list of attributes