Class HTMLWorker
- java.lang.Object
-
- com.lowagie.text.html.simpleparser.HTMLWorker
-
- All Implemented Interfaces:
DocListener,ElementListener,SimpleXMLDocHandler,AutoCloseable,EventListener
public class HTMLWorker extends Object implements SimpleXMLDocHandler, DocListener
-
-
Field Summary
Fields Modifier and Type Field Description protected DocListenerdocumentprotected ArrayList<Element>objectListstatic Map<String,Object>tagsSupportedstatic 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 Deprecated 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(String tag)Called when an end tag is found.Map<String,Object>getInterfaceProps()StyleSheetgetStyleSheet()booleannewPage()Signals that an new page has to be started.voidopen()Signals that theDocumenthas been opened and thatElementscan be added.voidparse(Reader reader)static ArrayList<Element>parseToList(Reader reader, StyleSheet style)static ArrayList<Element>parseToList(Reader reader, StyleSheet style, HashMap interfaceProps)Deprecated.useparseToList(Reader, StyleSheet, Map)since 1.2.22static ArrayList<Element>parseToList(Reader reader, StyleSheet style, Map<String,Object> 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(HashMap interfaceProps)Deprecated.usesetInterfaceProps(Map)since 1.2.22voidsetInterfaceProps(Map<String,Object> interfaceProps)booleansetMarginMirroring(boolean marginMirroring)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(String tag, HashMap h)Deprecated.usestartElement(String, Map)} since 1.2.22voidstartElement(String tag, Map<String,String> style)Called when a start tag is found.voidtext(String str)Called when a text element is found.
-
-
-
Field Detail
-
tagsSupportedString
public static final String tagsSupportedString
- See Also:
- Constant Field Values
-
document
protected DocListener document
-
-
Constructor Detail
-
HTMLWorker
public HTMLWorker(DocListener document)
Creates a new instance of HTMLWorker- Parameters:
document- A class that implementsDocListener
-
-
Method Detail
-
parseToList
public static ArrayList<Element> parseToList(Reader reader, StyleSheet style) throws IOException
- Throws:
IOException
-
parseToList
@Deprecated public static ArrayList<Element> parseToList(Reader reader, StyleSheet style, HashMap interfaceProps) throws IOException
Deprecated.useparseToList(Reader, StyleSheet, Map)since 1.2.22- Parameters:
reader- the Readerstyle- the StyleSheetinterfaceProps- the interface properties- Returns:
- an ArrayList
- Throws:
IOException- on error
-
parseToList
public static ArrayList<Element> parseToList(Reader reader, StyleSheet style, Map<String,Object> interfaceProps) throws IOException
- Throws:
IOException
-
getStyleSheet
public StyleSheet getStyleSheet()
-
setStyleSheet
public void setStyleSheet(StyleSheet style)
-
setInterfaceProps
@Deprecated public void setInterfaceProps(HashMap interfaceProps)
Deprecated.usesetInterfaceProps(Map)since 1.2.22- Parameters:
interfaceProps- the properties of the interface
-
parse
public void parse(Reader reader) throws IOException
- Throws:
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
@Deprecated public void startElement(String tag, HashMap h)
Deprecated.usestartElement(String, Map)} since 1.2.22Description copied from interface:SimpleXMLDocHandlerCalled when a start tag is found.- Specified by:
startElementin interfaceSimpleXMLDocHandler- Parameters:
tag- the tag nameh- the tag's attributes
-
startElement
public void startElement(String tag, Map<String,String> style)
Description copied from interface:SimpleXMLDocHandlerCalled when a start tag is found.- Specified by:
startElementin interfaceSimpleXMLDocHandler- Parameters:
tag- the tag namestyle- the tag's attributes
-
endElement
public void endElement(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(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 interfaceAutoCloseable- 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:DocListenerAllows you to do left/right margin mirroring (odd/even pages)- Specified by:
setMarginMirroringin interfaceDocListener- Parameters:
marginMirroring- left/right margin mirroring (odd/even pages)- 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- Parameters:
marginMirroring- top/bottom margin mirroring (odd/even pages)- 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
-
-