- java.lang.Object
-
- com.itextpdf.text.html.simpleparser.HTMLWorker
-
- All Implemented Interfaces:
DocListener,ElementListener,SimpleXMLDocHandler,java.util.EventListener
public class HTMLWorker extends java.lang.Object implements SimpleXMLDocHandler, DocListener
-
-
Field Summary
Fields Modifier and Type Field Description protected DocListenerdocumentprotected java.util.ArrayListobjectListstatic java.util.HashMaptagsSupportedstatic java.lang.StringtagsSupportedString
-
Constructor Summary
Constructors Constructor Description HTMLWorker(DocListener document)Creates a new instance of HTMLWorker
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(Element element)Signals that anElementwas added to theDocument.voidclearTextWrap()voidclose()Signals that theDocumentwas closed and that no otherElementswill be added.voidendDocument()Called after the document is parsed.voidendElement(java.lang.String tag)Called when an end tag is found.java.util.HashMapgetInterfaceProps()StyleSheetgetStyleSheet()booleannewPage()Signals that an new page has to be started.voidopen()Signals that theDocumenthas been opened and thatElementscan be added.voidparse(java.io.Reader reader)static java.util.ArrayListparseToList(java.io.Reader reader, StyleSheet style)static java.util.ArrayListparseToList(java.io.Reader reader, StyleSheet style, java.util.HashMap interfaceProps)voidresetFooter()Resets the footer of this document.voidresetHeader()Resets the header of this document.voidresetPageCount()Sets the page number to 0.voidsetFooter(HeaderFooter footer)Changes the footer of this document.voidsetHeader(HeaderFooter header)Changes the header of this document.voidsetInterfaceProps(java.util.HashMap interfaceProps)booleansetMarginMirroring(boolean marginMirroring)Parameter that allows you to do left/right margin mirroring (odd/even pages)booleansetMarginMirroringTopBottom(boolean marginMirroring)Parameter that allows you to do top/bottom margin mirroring (odd/even pages)booleansetMargins(float marginLeft, float marginRight, float marginTop, float marginBottom)Sets the margins.voidsetPageCount(int pageN)Sets the page number.booleansetPageSize(Rectangle pageSize)Sets the pagesize.voidsetStyleSheet(StyleSheet style)voidstartDocument()Called when the document starts to be parsed.voidstartElement(java.lang.String tag, java.util.HashMap h)Called when a start tag is found.voidtext(java.lang.String str)Called when a text element is found.
-
-
-
Field Detail
-
objectList
protected java.util.ArrayList objectList
-
document
protected DocListener document
-
tagsSupportedString
public static final java.lang.String tagsSupportedString
- See Also:
- Constant Field Values
-
tagsSupported
public static final java.util.HashMap tagsSupported
-
-
Constructor Detail
-
HTMLWorker
public HTMLWorker(DocListener document)
Creates a new instance of HTMLWorker- Parameters:
document- A class that implementsDocListener
-
-
Method Detail
-
setStyleSheet
public void setStyleSheet(StyleSheet style)
-
getStyleSheet
public StyleSheet getStyleSheet()
-
setInterfaceProps
public void setInterfaceProps(java.util.HashMap interfaceProps)
-
getInterfaceProps
public java.util.HashMap getInterfaceProps()
-
parse
public void parse(java.io.Reader reader) throws java.io.IOException- Throws:
java.io.IOException
-
parseToList
public static java.util.ArrayList parseToList(java.io.Reader reader, StyleSheet style) throws java.io.IOException- Throws:
java.io.IOException
-
parseToList
public static java.util.ArrayList parseToList(java.io.Reader reader, StyleSheet style, java.util.HashMap interfaceProps) throws java.io.IOException- Throws:
java.io.IOException
-
endDocument
public void endDocument()
Description copied from interface:SimpleXMLDocHandlerCalled after the document is parsed.- Specified by:
endDocumentin interfaceSimpleXMLDocHandler
-
startDocument
public void startDocument()
Description copied from interface:SimpleXMLDocHandlerCalled when the document starts to be parsed.- Specified by:
startDocumentin interfaceSimpleXMLDocHandler
-
startElement
public void startElement(java.lang.String tag, java.util.HashMap h)Description copied from interface:SimpleXMLDocHandlerCalled when a start tag is found.- Specified by:
startElementin interfaceSimpleXMLDocHandler- Parameters:
tag- the tag nameh- the tag's attributes
-
endElement
public void endElement(java.lang.String tag)
Description copied from interface:SimpleXMLDocHandlerCalled when an end tag is found.- Specified by:
endElementin interfaceSimpleXMLDocHandler- Parameters:
tag- the tag name
-
text
public void text(java.lang.String str)
Description copied from interface:SimpleXMLDocHandlerCalled when a text element is found.- Specified by:
textin interfaceSimpleXMLDocHandler- Parameters:
str- the text element, probably a fragment.
-
add
public boolean add(Element element) throws DocumentException
Description copied from interface:ElementListenerSignals that anElementwas added to theDocument.- Specified by:
addin interfaceElementListener- Parameters:
element- a high level object- Returns:
trueif the element was added,falseif not.- Throws:
DocumentException- when a document isn't open yet, or has been closed
-
clearTextWrap
public void clearTextWrap() throws DocumentException- Throws:
DocumentException
-
close
public void close()
Description copied from interface:DocListenerSignals that theDocumentwas closed and that no otherElementswill be added.The outputstream of every writer implementing
DocListenerwill be closed.- Specified by:
closein interfaceDocListener
-
newPage
public boolean newPage()
Description copied from interface:DocListenerSignals that an new page has to be started.- Specified by:
newPagein interfaceDocListener- Returns:
trueif the page was added,falseif not.
-
open
public void open()
Description copied from interface:DocListenerSignals that theDocumenthas been opened and thatElementscan be added.- Specified by:
openin interfaceDocListener
-
resetFooter
public void resetFooter()
Description copied from interface:DocListenerResets the footer of this document.- Specified by:
resetFooterin interfaceDocListener
-
resetHeader
public void resetHeader()
Description copied from interface:DocListenerResets the header of this document.- Specified by:
resetHeaderin interfaceDocListener
-
resetPageCount
public void resetPageCount()
Description copied from interface:DocListenerSets the page number to 0.- Specified by:
resetPageCountin interfaceDocListener
-
setFooter
public void setFooter(HeaderFooter footer)
Description copied from interface:DocListenerChanges the footer of this document.- Specified by:
setFooterin interfaceDocListener- Parameters:
footer- the new footer
-
setHeader
public void setHeader(HeaderFooter header)
Description copied from interface:DocListenerChanges the header of this document.- Specified by:
setHeaderin interfaceDocListener- Parameters:
header- the new header
-
setMarginMirroring
public boolean setMarginMirroring(boolean marginMirroring)
Description copied from interface:DocListenerParameter that allows you to do left/right margin mirroring (odd/even pages)- Specified by:
setMarginMirroringin interfaceDocListener- Returns:
- true if successful
-
setMarginMirroringTopBottom
public boolean setMarginMirroringTopBottom(boolean marginMirroring)
Description copied from interface:DocListenerParameter that allows you to do top/bottom margin mirroring (odd/even pages)- Specified by:
setMarginMirroringTopBottomin interfaceDocListener- Returns:
- true if successful
- Since:
- 2.1.6
- See Also:
DocListener.setMarginMirroring(boolean)
-
setMargins
public boolean setMargins(float marginLeft, float marginRight, float marginTop, float marginBottom)Description copied from interface:DocListenerSets the margins.- Specified by:
setMarginsin interfaceDocListener- Parameters:
marginLeft- the margin on the leftmarginRight- the margin on the rightmarginTop- the margin on the topmarginBottom- the margin on the bottom- Returns:
- a
boolean
-
setPageCount
public void setPageCount(int pageN)
Description copied from interface:DocListenerSets the page number.- Specified by:
setPageCountin interfaceDocListener- Parameters:
pageN- the new page number
-
setPageSize
public boolean setPageSize(Rectangle pageSize)
Description copied from interface:DocListenerSets the pagesize.- Specified by:
setPageSizein interfaceDocListener- Parameters:
pageSize- the new pagesize- Returns:
- a
boolean
-
-