java.lang.Object
com.lowagie.text.html.simpleparser.HTMLWorker
- All Implemented Interfaces:
DocListener,ElementListener,SimpleXMLDocHandler,AutoCloseable,EventListener
@Deprecated(since="2.1.0")
public class HTMLWorker
extends Object
implements SimpleXMLDocHandler, DocListener
Deprecated.
This class is a simple parser for HTML.
Security consideration: This method accepts input and processes it without built-in validation,
filtering, or access restrictions. It may load resources such as local files or external URLs,
depending on the input. This can introduce security risks including unauthorized file access,
directory traversal, or server-side request forgery (SSRF).
It is the responsibility of the calling application to validate and sanitize all input
before passing it to this method, especially when handling user-controlled or external data.
Refer to established secure coding guidelines to ensure safe usage.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected DocListenerDeprecated.Deprecated.Deprecated.static final StringDeprecated. -
Constructor Summary
ConstructorsConstructorDescriptionHTMLWorker(DocListener document) Deprecated.Creates a new instance of HTMLWorker -
Method Summary
Modifier and TypeMethodDescriptionbooleanDeprecated.Signals that anElementwas added to theDocument.voidDeprecated.voidclose()Deprecated.Signals that theDocumentwas closed and that no otherElementswill be added.voidDeprecated.Called after the document is parsed.voidendElement(String tag) Deprecated.Called when an end tag is found.Deprecated.Deprecated.booleannewPage()Deprecated.Signals that an new page has to be started.voidopen()Deprecated.Signals that theDocumenthas been opened and thatElementscan be added.voidDeprecated.Parses the HTML document.parseToList(Reader reader, StyleSheet style) Deprecated.parseToList(Reader reader, StyleSheet style, Map<String, Object> interfaceProps) Deprecated.Parses the HTML document and returns a list of elements.voidDeprecated.Resets the footer of this document.voidDeprecated.Resets the header of this document.voidDeprecated.Sets the page number to 0.voidsetFooter(HeaderFooter footer) Deprecated.Changes the footer of this document.voidsetHeader(HeaderFooter header) Deprecated.Changes the header of this document.voidsetInterfaceProps(Map<String, Object> interfaceProps) Deprecated.booleansetMarginMirroring(boolean marginMirroring) Deprecated.Allows you to do left/right margin mirroring (odd/even pages)booleansetMarginMirroringTopBottom(boolean marginMirroring) Deprecated.Parameter that allows you to do top/bottom margin mirroring (odd/even pages)booleansetMargins(float marginLeft, float marginRight, float marginTop, float marginBottom) Deprecated.Sets the margins.voidsetPageCount(int pageN) Deprecated.Sets the page number.booleansetPageSize(Rectangle pageSize) Deprecated.Sets the pagesize.voidsetStyleSheet(StyleSheet style) Deprecated.voidDeprecated.Called when the document starts to be parsed.voidstartElement(String tag, Map<String, String> style) Deprecated.Called when a start tag is found.voidDeprecated.Called when a text element is found.
-
Field Details
-
tagsSupportedString
Deprecated.- See Also:
-
tagsSupported
Deprecated. -
objectList
Deprecated. -
document
Deprecated.
-
-
Constructor Details
-
HTMLWorker
Deprecated.Creates a new instance of HTMLWorker- Parameters:
document- A class that implementsDocListener
-
-
Method Details
-
parseToList
Deprecated.- Throws:
IOException
-
parseToList
public static ArrayList<Element> parseToList(Reader reader, StyleSheet style, Map<String, Object> interfaceProps) throws IOExceptionDeprecated.Parses the HTML document and returns a list of elements. Security consideration: This method accepts input and processes it without built-in validation, filtering, or access restrictions. It may load resources such as local files or external URLs, depending on the input. This can introduce security risks including unauthorized file access, directory traversal, or server-side request forgery (SSRF). It is the responsibility of the calling application to validate and sanitize all input before passing it to this method, especially when handling user-controlled or external data. Refer to established secure coding guidelines to ensure safe usage.- Parameters:
reader-style-interfaceProps-- Returns:
- Throws:
IOException
-
getStyleSheet
Deprecated. -
setStyleSheet
Deprecated. -
getInterfaceProps
Deprecated. -
setInterfaceProps
Deprecated. -
parse
Deprecated.Parses the HTML document. Security consideration: This method accepts input and processes it without built-in validation, filtering, or access restrictions. It may load resources such as local files or external URLs, depending on the input. This can introduce security risks including unauthorized file access, directory traversal, or server-side request forgery (SSRF). It is the responsibility of the calling application to validate and sanitize all input before passing it to this method, especially when handling user-controlled or external data. Refer to established secure coding guidelines to ensure safe usage.- Parameters:
reader-- Throws:
IOException
-
endDocument
public void endDocument()Deprecated.Description copied from interface:SimpleXMLDocHandlerCalled after the document is parsed.- Specified by:
endDocumentin interfaceSimpleXMLDocHandler
-
startDocument
public void startDocument()Deprecated.Description copied from interface:SimpleXMLDocHandlerCalled when the document starts to be parsed.- Specified by:
startDocumentin interfaceSimpleXMLDocHandler
-
startElement
Deprecated.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
Deprecated.Description copied from interface:SimpleXMLDocHandlerCalled when an end tag is found.- Specified by:
endElementin interfaceSimpleXMLDocHandler- Parameters:
tag- the tag name
-
text
Deprecated.Description copied from interface:SimpleXMLDocHandlerCalled when a text element is found.- Specified by:
textin interfaceSimpleXMLDocHandler- Parameters:
str- the text element, probably a fragment.
-
add
Deprecated.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
Deprecated.- Throws:
DocumentException
-
close
public void close()Deprecated.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()Deprecated.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()Deprecated.Description copied from interface:DocListenerSignals that theDocumenthas been opened and thatElementscan be added.- Specified by:
openin interfaceDocListener
-
resetHeader
public void resetHeader()Deprecated.Description copied from interface:DocListenerResets the header of this document.- Specified by:
resetHeaderin interfaceDocListener
-
resetPageCount
public void resetPageCount()Deprecated.Description copied from interface:DocListenerSets the page number to 0.- Specified by:
resetPageCountin interfaceDocListener
-
setMarginMirroring
public boolean setMarginMirroring(boolean marginMirroring) Deprecated.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) Deprecated.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:
-
setMargins
public boolean setMargins(float marginLeft, float marginRight, float marginTop, float marginBottom) Deprecated.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) Deprecated.Description copied from interface:DocListenerSets the page number.- Specified by:
setPageCountin interfaceDocListener- Parameters:
pageN- the new page number
-
setPageSize
Deprecated.Description copied from interface:DocListenerSets the pagesize.- Specified by:
setPageSizein interfaceDocListener- Parameters:
pageSize- the new pagesize- Returns:
- a
boolean
-