Class HTMLWorker
java.lang.Object
com.itextpdf.text.html.simpleparser.HTMLWorker
- All Implemented Interfaces:
DocListener
,ElementListener
,SimpleXMLDocHandler
,EventListener
Deprecated.
since 5.5.2; please switch to XML Worker instead (this is a separate project)
Old iText class that allows you to convert HTML to PDF.
We've completely rewritten HTML to PDF conversion and we made it a separate project named XML Worker.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ChainedProperties
Deprecated.The current hierarchy chain of tags.protected Paragraph
Deprecated.Keeps the content of the current paragraphprotected DocListener
Deprecated.DocListener that will listen to the Elements produced by parsing the HTML.private final ElementFactory
Deprecated.Factory that is able to create iText Element objects.static final String
Deprecated.Key used to store the font provider in the providers map.static final String
Deprecated.Key used to store the image baseurl provider in the providers map.static final String
Deprecated.Key used to store the image processor in the providers map.static final String
Deprecated.Key used to store the image provider in the providers map.static final String
Deprecated.Key used to store the image store in the providers map.private boolean
Deprecated.Boolean to keep track of PRE tagsstatic final String
Deprecated.Key used to store the link provider in the providers map.private static Logger
Deprecated.Deprecated.The resulting list of elements.private boolean
Deprecated.Boolean to keep track of LI tagsprivate boolean
Deprecated.Boolean to keep track of TD and TH tagsprivate boolean
Deprecated.Boolean to keep track of TR tags.Deprecated.Map containing providers such as a FontProvider or ImageProvider.protected boolean
Deprecated.Indicates if text needs to be skipped.Deprecated.Stack with the Elements that already have been processed.private StyleSheet
Deprecated.The object defining all the styles.private final Stack<boolean[]>
Deprecated.Stack to keep track of table tags.protected Map<String,
HTMLTagProcessor> Deprecated.The map with all the supported tags. -
Constructor Summary
ConstructorsConstructorDescriptionHTMLWorker
(DocListener document) Deprecated.Creates a new instance of HTMLWorkerHTMLWorker
(DocListener document, Map<String, HTMLTagProcessor> tags, StyleSheet style) Deprecated.Creates a new instance of HTMLWorker -
Method Summary
Modifier and TypeMethodDescriptionboolean
Deprecated.Signals that anElement
was added to theDocument
.void
Deprecated.Flushes the current paragraph, indicating that we're starting a new block.void
close()
Deprecated.Signals that theDocument
was closed and that no otherElements
will be added.createCell
(String tag) Deprecated.Creates a Cell.createChunk
(String content) Deprecated.Creates a Chunk using the factory.createImage
(Map<String, String> attrs) Deprecated.Creates an Image object.createLineSeparator
(Map<String, String> attrs) Deprecated.Creates a LineSeparator object.createList
(String tag) Deprecated.Creates a List object.Deprecated.Creates a ListItem object.Deprecated.Creates a Paragraph using the factory.void
Deprecated.Called after the document is parsed.void
endElement
(String tag) Deprecated.Called when an end tag is found.void
Deprecated.Stacks the current paragraph, indicating that we're starting a new span.Deprecated.use getProviders() insteadboolean
Deprecated.boolean
Deprecated.boolean
Deprecated.boolean
Deprecated.boolean
Deprecated.void
newLine()
Deprecated.Adds a new line to the currentParagraph.boolean
newPage()
Deprecated.Signals that an new page has to be started.void
open()
Deprecated.Signals that theDocument
has been opened and thatElements
can be added.void
Deprecated.Parses content read from a java.io.Reader object.parseToList
(Reader reader, StyleSheet style) Deprecated.Parses an HTML source to a List of Element objectsparseToList
(Reader reader, StyleSheet style, HashMap<String, Object> providers) Deprecated.Parses an HTML source to a List of Element objectsparseToList
(Reader reader, StyleSheet style, Map<String, HTMLTagProcessor> tags, HashMap<String, Object> providers) Deprecated.Parses an HTML source to a List of Element objectsvoid
Deprecated.Pops the values of pendingTR and pendingTD from a state stack.void
processImage
(Image img, Map<String, String> attrs) Deprecated.Processes an Image.void
Deprecated.Adds a link to the current paragraph.void
Deprecated.Fetches the List from the Stack and adds it to the TextElementArray on top of the Stack, or to the Document if the Stack is empty.void
Deprecated.Looks for the List object on the Stack, and adds the ListItem to the List.void
Deprecated.Gets the TableWrapper from the Stack and adds a new row.void
Deprecated.Processes the Table.void
Deprecated.Pushes the values of pendingTR and pendingTD to a state stack.void
pushToStack
(Element element) Deprecated.Pushes an element to the Stack.void
Deprecated.Sets the page number to 0.void
setInsidePRE
(boolean insidePRE) Deprecated.void
setInterfaceProps
(HashMap<String, Object> providers) Deprecated.use setProviders() insteadboolean
setMarginMirroring
(boolean marginMirroring) Deprecated.Parameter that allows you to do left/right margin mirroring (odd/even pages)boolean
setMarginMirroringTopBottom
(boolean marginMirroring) Deprecated.Parameter that allows you to do top/bottom margin mirroring (odd/even pages)boolean
setMargins
(float marginLeft, float marginRight, float marginTop, float marginBottom) Deprecated.Sets the margins.void
setPageCount
(int pageN) Deprecated.Sets the page number.boolean
setPageSize
(Rectangle pageSize) Deprecated.Sets the pagesize.void
setPendingLI
(boolean pendingLI) Deprecated.void
setPendingTD
(boolean pendingTD) Deprecated.void
setPendingTR
(boolean pendingTR) Deprecated.void
setProviders
(Map<String, Object> providers) Deprecated.Setter for the providers.void
setSkipText
(boolean skipText) Deprecated.void
setStyleSheet
(StyleSheet style) Deprecated.Setter for the StyleSheetvoid
Deprecated.Sets the map with supported tags.void
Deprecated.Called when the document starts to be parsed.void
startElement
(String tag, Map<String, String> attrs) Deprecated.Called when a start tag is found.void
Deprecated.Called when a text element is found.void
updateChain
(String tag) Deprecated.Updates the chain by removing a tag.void
updateChain
(String tag, Map<String, String> attrs) Deprecated.Updates the chain with a new tag and new attributes.
-
Field Details
-
LOGGER
Deprecated. -
document
Deprecated.DocListener that will listen to the Elements produced by parsing the HTML. This can be a com.lowagie.text.Document adding the elements to a Document directly, or an HTMLWorker instance strong the objects in a List -
tags
Deprecated.The map with all the supported tags.- Since:
- 5.0.6
-
style
Deprecated.The object defining all the styles. -
stack
Deprecated.Stack with the Elements that already have been processed.- Since:
- iText 5.0.6 (private => protected)
-
currentParagraph
Deprecated.Keeps the content of the current paragraph- Since:
- iText 5.0.6 (private => protected)
-
chain
Deprecated.The current hierarchy chain of tags.- Since:
- 5.0.6
-
IMG_PROVIDER
Deprecated.Key used to store the image provider in the providers map.- Since:
- 5.0.6
- See Also:
-
IMG_PROCESSOR
Deprecated.Key used to store the image processor in the providers map.- Since:
- 5.0.6
- See Also:
-
IMG_STORE
Deprecated.Key used to store the image store in the providers map.- Since:
- 5.0.6
- See Also:
-
IMG_BASEURL
Deprecated.Key used to store the image baseurl provider in the providers map.- Since:
- 5.0.6
- See Also:
-
FONT_PROVIDER
Deprecated.Key used to store the font provider in the providers map.- Since:
- 5.0.6
- See Also:
-
LINK_PROVIDER
Deprecated.Key used to store the link provider in the providers map.- Since:
- 5.0.6
- See Also:
-
providers
Deprecated.Map containing providers such as a FontProvider or ImageProvider.- Since:
- 5.0.6 (renamed from interfaceProps)
-
factory
Deprecated.Factory that is able to create iText Element objects.- Since:
- 5.0.6
-
tableState
Deprecated.Stack to keep track of table tags. -
pendingTR
private boolean pendingTRDeprecated.Boolean to keep track of TR tags. -
pendingTD
private boolean pendingTDDeprecated.Boolean to keep track of TD and TH tags -
pendingLI
private boolean pendingLIDeprecated.Boolean to keep track of LI tags -
insidePRE
private boolean insidePREDeprecated.Boolean to keep track of PRE tags- Since:
- 5.0.6 renamed from isPRE
-
skipText
protected boolean skipTextDeprecated.Indicates if text needs to be skipped.- Since:
- iText 5.0.6 (private => protected)
-
objectList
Deprecated.The resulting list of elements.
-
-
Constructor Details
-
HTMLWorker
Deprecated.Creates a new instance of HTMLWorker- Parameters:
document
- A class that implementsDocListener
-
HTMLWorker
Deprecated.Creates a new instance of HTMLWorker- Parameters:
document
- A class that implementsDocListener
tags
- A map containing the supported tagsstyle
- A StyleSheet- Since:
- 5.0.6
-
-
Method Details
-
setSupportedTags
Deprecated.Sets the map with supported tags.- Parameters:
tags
-- Since:
- 5.0.6
-
setStyleSheet
Deprecated.Setter for the StyleSheet- Parameters:
style
- the StyleSheet
-
parse
Deprecated.Parses content read from a java.io.Reader object.- Parameters:
reader
- the content- Throws:
IOException
-
startDocument
public void startDocument()Deprecated.Description copied from interface:SimpleXMLDocHandler
Called when the document starts to be parsed.- Specified by:
startDocument
in interfaceSimpleXMLDocHandler
- See Also:
-
startElement
Deprecated.Description copied from interface:SimpleXMLDocHandler
Called when a start tag is found.- Specified by:
startElement
in interfaceSimpleXMLDocHandler
- Parameters:
tag
- the tag nameattrs
- the tag's attributes- See Also:
-
text
Deprecated.Description copied from interface:SimpleXMLDocHandler
Called when a text element is found.- Specified by:
text
in interfaceSimpleXMLDocHandler
- Parameters:
content
- the text element, probably a fragment.- See Also:
-
endElement
Deprecated.Description copied from interface:SimpleXMLDocHandler
Called when an end tag is found.- Specified by:
endElement
in interfaceSimpleXMLDocHandler
- Parameters:
tag
- the tag name- See Also:
-
endDocument
public void endDocument()Deprecated.Description copied from interface:SimpleXMLDocHandler
Called after the document is parsed.- Specified by:
endDocument
in interfaceSimpleXMLDocHandler
- See Also:
-
newLine
public void newLine()Deprecated.Adds a new line to the currentParagraph.- Since:
- 5.0.6
-
carriageReturn
Deprecated.Flushes the current paragraph, indicating that we're starting a new block. If the stack is empty, the paragraph is added to the document. Otherwise the Paragraph is added to the stack.- Throws:
DocumentException
- Since:
- 5.0.6
-
flushContent
public void flushContent()Deprecated.Stacks the current paragraph, indicating that we're starting a new span.- Since:
- 5.0.6
-
pushToStack
Deprecated.Pushes an element to the Stack.- Parameters:
element
-- Since:
- 5.0.6
-
updateChain
Deprecated.Updates the chain with a new tag and new attributes.- Parameters:
tag
- the new tagattrs
- the corresponding attributes- Since:
- 5.0.6
-
updateChain
Deprecated.Updates the chain by removing a tag.- Parameters:
tag
- the new tag- Since:
- 5.0.6
-
setProviders
Deprecated.Setter for the providers. If a FontProvider is added, the ElementFactory is updated.- Parameters:
providers
- a Map with different providers- Since:
- 5.0.6
-
createChunk
Deprecated.Creates a Chunk using the factory.- Parameters:
content
- the content of the chunk- Returns:
- a Chunk with content
- Since:
- 5.0.6
-
createParagraph
Deprecated.Creates a Paragraph using the factory.- Returns:
- a Paragraph without any content
- Since:
- 5.0.6
-
createList
Deprecated.Creates a List object.- Parameters:
tag
- should be "ol" or "ul"- Returns:
- a List object
- Since:
- 5.0.6
-
createListItem
Deprecated.Creates a ListItem object.- Returns:
- a ListItem object
- Since:
- 5.0.6
-
createLineSeparator
Deprecated.Creates a LineSeparator object.- Parameters:
attrs
- properties of the LineSeparator- Returns:
- a LineSeparator object
- Since:
- 5.0.6
-
createImage
Deprecated.Creates an Image object.- Parameters:
attrs
- properties of the Image- Returns:
- an Image object (or null if the Image couldn't be found)
- Throws:
DocumentException
IOException
- Since:
- 5.0.6
-
createCell
Deprecated.Creates a Cell.- Parameters:
tag
- the tag- Returns:
- a CellWrapper object
- Since:
- 5.0.6
-
processLink
public void processLink()Deprecated.Adds a link to the current paragraph.- Since:
- 5.0.6
-
processList
Deprecated.Fetches the List from the Stack and adds it to the TextElementArray on top of the Stack, or to the Document if the Stack is empty.- Throws:
DocumentException
- Since:
- 5.0.6
-
processListItem
Deprecated.Looks for the List object on the Stack, and adds the ListItem to the List.- Throws:
DocumentException
- Since:
- 5.0.6
-
processImage
Deprecated.Processes an Image.- Parameters:
img
-attrs
-- Throws:
DocumentException
- Since:
- 5.0.6
-
processTable
Deprecated.Processes the Table.- Throws:
DocumentException
- Since:
- 5.0.6
-
processRow
public void processRow()Deprecated.Gets the TableWrapper from the Stack and adds a new row.- Since:
- 5.0.6
-
pushTableState
public void pushTableState()Deprecated.Pushes the values of pendingTR and pendingTD to a state stack.- Since:
- 5.0.6
-
popTableState
public void popTableState()Deprecated.Pops the values of pendingTR and pendingTD from a state stack.- Since:
- 5.0.6
-
isPendingTR
public boolean isPendingTR()Deprecated.- Returns:
- the pendingTR
- Since:
- 5.0.6
-
setPendingTR
public void setPendingTR(boolean pendingTR) Deprecated.- Parameters:
pendingTR
- the pendingTR to set- Since:
- 5.0.6
-
isPendingTD
public boolean isPendingTD()Deprecated.- Returns:
- the pendingTD
- Since:
- 5.0.6
-
setPendingTD
public void setPendingTD(boolean pendingTD) Deprecated.- Parameters:
pendingTD
- the pendingTD to set- Since:
- 5.0.6
-
isPendingLI
public boolean isPendingLI()Deprecated.- Returns:
- the pendingLI
- Since:
- 5.0.6
-
setPendingLI
public void setPendingLI(boolean pendingLI) Deprecated.- Parameters:
pendingLI
- the pendingLI to set- Since:
- 5.0.6
-
isInsidePRE
public boolean isInsidePRE()Deprecated.- Returns:
- the insidePRE
- Since:
- 5.0.6
-
setInsidePRE
public void setInsidePRE(boolean insidePRE) Deprecated.- Parameters:
insidePRE
- the insidePRE to set- Since:
- 5.0.6
-
isSkipText
public boolean isSkipText()Deprecated.- Returns:
- the skipText
- Since:
- 5.0.6
-
setSkipText
public void setSkipText(boolean skipText) Deprecated.- Parameters:
skipText
- the skipText to set- Since:
- 5.0.6
-
parseToList
Deprecated.Parses an HTML source to a List of Element objects- Parameters:
reader
- the HTML sourcestyle
- a StyleSheet object- Returns:
- a List of Element objects
- Throws:
IOException
-
parseToList
public static List<Element> parseToList(Reader reader, StyleSheet style, HashMap<String, Object> providers) throws IOExceptionDeprecated.Parses an HTML source to a List of Element objects- Parameters:
reader
- the HTML sourcestyle
- a StyleSheet objectproviders
- map containing classes with extra info- Returns:
- a List of Element objects
- Throws:
IOException
-
parseToList
public static List<Element> parseToList(Reader reader, StyleSheet style, Map<String, HTMLTagProcessor> tags, HashMap<String, throws IOExceptionObject> providers) Deprecated.Parses an HTML source to a List of Element objects- Parameters:
reader
- the HTML sourcestyle
- a StyleSheet objecttags
- a map containing supported tags and their processorsproviders
- map containing classes with extra info- Returns:
- a List of Element objects
- Throws:
IOException
- Since:
- 5.0.6
-
add
Deprecated.Description copied from interface:ElementListener
Signals that anElement
was added to theDocument
.- Specified by:
add
in interfaceElementListener
- Parameters:
element
- a high level object- Returns:
true
if the element was added,false
if not.- Throws:
DocumentException
- when a document isn't open yet, or has been closed- See Also:
-
close
public void close()Deprecated.Description copied from interface:DocListener
Signals that theDocument
was closed and that no otherElements
will be added.The outputstream of every writer implementing
DocListener
will be closed.- Specified by:
close
in interfaceDocListener
- See Also:
-
newPage
public boolean newPage()Deprecated.Description copied from interface:DocListener
Signals that an new page has to be started.- Specified by:
newPage
in interfaceDocListener
- Returns:
true
if the page was added,false
if not.- See Also:
-
open
public void open()Deprecated.Description copied from interface:DocListener
Signals that theDocument
has been opened and thatElements
can be added.- Specified by:
open
in interfaceDocListener
- See Also:
-
resetPageCount
public void resetPageCount()Deprecated.Description copied from interface:DocListener
Sets the page number to 0.- Specified by:
resetPageCount
in interfaceDocListener
- See Also:
-
setMarginMirroring
public boolean setMarginMirroring(boolean marginMirroring) Deprecated.Description copied from interface:DocListener
Parameter that allows you to do left/right margin mirroring (odd/even pages)- Specified by:
setMarginMirroring
in interfaceDocListener
- Returns:
- true if successful
- See Also:
-
setMarginMirroringTopBottom
public boolean setMarginMirroringTopBottom(boolean marginMirroring) Deprecated.Description copied from interface:DocListener
Parameter that allows you to do top/bottom margin mirroring (odd/even pages)- Specified by:
setMarginMirroringTopBottom
in interfaceDocListener
- 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:DocListener
Sets the margins.- Specified by:
setMargins
in 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
- See Also:
-
setPageCount
public void setPageCount(int pageN) Deprecated.Description copied from interface:DocListener
Sets the page number.- Specified by:
setPageCount
in interfaceDocListener
- Parameters:
pageN
- the new page number- See Also:
-
setPageSize
Deprecated.Description copied from interface:DocListener
Sets the pagesize.- Specified by:
setPageSize
in interfaceDocListener
- Parameters:
pageSize
- the new pagesize- Returns:
- a
boolean
- See Also:
-
setInterfaceProps
Deprecated.use setProviders() insteadSets the providers. -
getInterfaceProps
Deprecated.use getProviders() insteadGets the providers
-