Class HTMLWorker
- java.lang.Object
-
- com.itextpdf.text.html.simpleparser.HTMLWorker
-
- All Implemented Interfaces:
DocListener,ElementListener,SimpleXMLDocHandler,java.util.EventListener
@Deprecated public class HTMLWorker extends java.lang.Object implements SimpleXMLDocHandler, DocListener
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
Fields Modifier and Type Field Description private ChainedPropertieschainDeprecated.The current hierarchy chain of tags.protected ParagraphcurrentParagraphDeprecated.Keeps the content of the current paragraphprotected DocListenerdocumentDeprecated.DocListener that will listen to the Elements produced by parsing the HTML.private ElementFactoryfactoryDeprecated.Factory that is able to create iText Element objects.static java.lang.StringFONT_PROVIDERDeprecated.Key used to store the font provider in the providers map.static java.lang.StringIMG_BASEURLDeprecated.Key used to store the image baseurl provider in the providers map.static java.lang.StringIMG_PROCESSORDeprecated.Key used to store the image processor in the providers map.static java.lang.StringIMG_PROVIDERDeprecated.Key used to store the image provider in the providers map.static java.lang.StringIMG_STOREDeprecated.Key used to store the image store in the providers map.private booleaninsidePREDeprecated.Boolean to keep track of PRE tagsstatic java.lang.StringLINK_PROVIDERDeprecated.Key used to store the link provider in the providers map.private static LoggerLOGGERDeprecated.protected java.util.List<Element>objectListDeprecated.The resulting list of elements.private booleanpendingLIDeprecated.Boolean to keep track of LI tagsprivate booleanpendingTDDeprecated.Boolean to keep track of TD and TH tagsprivate booleanpendingTRDeprecated.Boolean to keep track of TR tags.private java.util.Map<java.lang.String,java.lang.Object>providersDeprecated.Map containing providers such as a FontProvider or ImageProvider.protected booleanskipTextDeprecated.Indicates if text needs to be skipped.protected java.util.Stack<Element>stackDeprecated.Stack with the Elements that already have been processed.private StyleSheetstyleDeprecated.The object defining all the styles.private java.util.Stack<boolean[]>tableStateDeprecated.Stack to keep track of table tags.protected java.util.Map<java.lang.String,HTMLTagProcessor>tagsDeprecated.The map with all the supported tags.
-
Constructor Summary
Constructors Constructor Description HTMLWorker(DocListener document)Deprecated.Creates a new instance of HTMLWorkerHTMLWorker(DocListener document, java.util.Map<java.lang.String,HTMLTagProcessor> tags, StyleSheet style)Deprecated.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)Deprecated.Signals that anElementwas added to theDocument.voidcarriageReturn()Deprecated.Flushes the current paragraph, indicating that we're starting a new block.voidclose()Deprecated.Signals that theDocumentwas closed and that no otherElementswill be added.CellWrappercreateCell(java.lang.String tag)Deprecated.Creates a Cell.ChunkcreateChunk(java.lang.String content)Deprecated.Creates a Chunk using the factory.ImagecreateImage(java.util.Map<java.lang.String,java.lang.String> attrs)Deprecated.Creates an Image object.LineSeparatorcreateLineSeparator(java.util.Map<java.lang.String,java.lang.String> attrs)Deprecated.Creates a LineSeparator object.ListcreateList(java.lang.String tag)Deprecated.Creates a List object.ListItemcreateListItem()Deprecated.Creates a ListItem object.ParagraphcreateParagraph()Deprecated.Creates a Paragraph using the factory.voidendDocument()Deprecated.Called after the document is parsed.voidendElement(java.lang.String tag)Deprecated.Called when an end tag is found.voidflushContent()Deprecated.Stacks the current paragraph, indicating that we're starting a new span.java.util.Map<java.lang.String,java.lang.Object>getInterfaceProps()Deprecated.use getProviders() insteadbooleanisInsidePRE()Deprecated.booleanisPendingLI()Deprecated.booleanisPendingTD()Deprecated.booleanisPendingTR()Deprecated.booleanisSkipText()Deprecated.voidnewLine()Deprecated.Adds a new line to the currentParagraph.booleannewPage()Deprecated.Signals that an new page has to be started.voidopen()Deprecated.Signals that theDocumenthas been opened and thatElementscan be added.voidparse(java.io.Reader reader)Deprecated.Parses content read from a java.io.Reader object.static java.util.List<Element>parseToList(java.io.Reader reader, StyleSheet style)Deprecated.Parses an HTML source to a List of Element objectsstatic java.util.List<Element>parseToList(java.io.Reader reader, StyleSheet style, java.util.HashMap<java.lang.String,java.lang.Object> providers)Deprecated.Parses an HTML source to a List of Element objectsstatic java.util.List<Element>parseToList(java.io.Reader reader, StyleSheet style, java.util.Map<java.lang.String,HTMLTagProcessor> tags, java.util.HashMap<java.lang.String,java.lang.Object> providers)Deprecated.Parses an HTML source to a List of Element objectsvoidpopTableState()Deprecated.Pops the values of pendingTR and pendingTD from a state stack.voidprocessImage(Image img, java.util.Map<java.lang.String,java.lang.String> attrs)Deprecated.Processes an Image.voidprocessLink()Deprecated.Adds a link to the current paragraph.voidprocessList()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.voidprocessListItem()Deprecated.Looks for the List object on the Stack, and adds the ListItem to the List.voidprocessRow()Deprecated.Gets the TableWrapper from the Stack and adds a new row.voidprocessTable()Deprecated.Processes the Table.voidpushTableState()Deprecated.Pushes the values of pendingTR and pendingTD to a state stack.voidpushToStack(Element element)Deprecated.Pushes an element to the Stack.voidresetPageCount()Deprecated.Sets the page number to 0.voidsetInsidePRE(boolean insidePRE)Deprecated.voidsetInterfaceProps(java.util.HashMap<java.lang.String,java.lang.Object> providers)Deprecated.use setProviders() insteadbooleansetMarginMirroring(boolean marginMirroring)Deprecated.Parameter that 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.voidsetPendingLI(boolean pendingLI)Deprecated.voidsetPendingTD(boolean pendingTD)Deprecated.voidsetPendingTR(boolean pendingTR)Deprecated.voidsetProviders(java.util.Map<java.lang.String,java.lang.Object> providers)Deprecated.Setter for the providers.voidsetSkipText(boolean skipText)Deprecated.voidsetStyleSheet(StyleSheet style)Deprecated.Setter for the StyleSheetvoidsetSupportedTags(java.util.Map<java.lang.String,HTMLTagProcessor> tags)Deprecated.Sets the map with supported tags.voidstartDocument()Deprecated.Called when the document starts to be parsed.voidstartElement(java.lang.String tag, java.util.Map<java.lang.String,java.lang.String> attrs)Deprecated.Called when a start tag is found.voidtext(java.lang.String content)Deprecated.Called when a text element is found.voidupdateChain(java.lang.String tag)Deprecated.Updates the chain by removing a tag.voidupdateChain(java.lang.String tag, java.util.Map<java.lang.String,java.lang.String> attrs)Deprecated.Updates the chain with a new tag and new attributes.
-
-
-
Field Detail
-
LOGGER
private static Logger LOGGER
Deprecated.
-
document
protected DocListener 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
protected java.util.Map<java.lang.String,HTMLTagProcessor> tags
Deprecated.The map with all the supported tags.- Since:
- 5.0.6
-
style
private StyleSheet style
Deprecated.The object defining all the styles.
-
stack
protected java.util.Stack<Element> stack
Deprecated.Stack with the Elements that already have been processed.- Since:
- iText 5.0.6 (private => protected)
-
currentParagraph
protected Paragraph currentParagraph
Deprecated.Keeps the content of the current paragraph- Since:
- iText 5.0.6 (private => protected)
-
chain
private final ChainedProperties chain
Deprecated.The current hierarchy chain of tags.- Since:
- 5.0.6
-
IMG_PROVIDER
public static final java.lang.String IMG_PROVIDER
Deprecated.Key used to store the image provider in the providers map.- Since:
- 5.0.6
- See Also:
- Constant Field Values
-
IMG_PROCESSOR
public static final java.lang.String IMG_PROCESSOR
Deprecated.Key used to store the image processor in the providers map.- Since:
- 5.0.6
- See Also:
- Constant Field Values
-
IMG_STORE
public static final java.lang.String IMG_STORE
Deprecated.Key used to store the image store in the providers map.- Since:
- 5.0.6
- See Also:
- Constant Field Values
-
IMG_BASEURL
public static final java.lang.String IMG_BASEURL
Deprecated.Key used to store the image baseurl provider in the providers map.- Since:
- 5.0.6
- See Also:
- Constant Field Values
-
FONT_PROVIDER
public static final java.lang.String FONT_PROVIDER
Deprecated.Key used to store the font provider in the providers map.- Since:
- 5.0.6
- See Also:
- Constant Field Values
-
LINK_PROVIDER
public static final java.lang.String LINK_PROVIDER
Deprecated.Key used to store the link provider in the providers map.- Since:
- 5.0.6
- See Also:
- Constant Field Values
-
providers
private java.util.Map<java.lang.String,java.lang.Object> providers
Deprecated.Map containing providers such as a FontProvider or ImageProvider.- Since:
- 5.0.6 (renamed from interfaceProps)
-
factory
private final ElementFactory factory
Deprecated.Factory that is able to create iText Element objects.- Since:
- 5.0.6
-
tableState
private final java.util.Stack<boolean[]> tableState
Deprecated.Stack to keep track of table tags.
-
pendingTR
private boolean pendingTR
Deprecated.Boolean to keep track of TR tags.
-
pendingTD
private boolean pendingTD
Deprecated.Boolean to keep track of TD and TH tags
-
pendingLI
private boolean pendingLI
Deprecated.Boolean to keep track of LI tags
-
insidePRE
private boolean insidePRE
Deprecated.Boolean to keep track of PRE tags- Since:
- 5.0.6 renamed from isPRE
-
skipText
protected boolean skipText
Deprecated.Indicates if text needs to be skipped.- Since:
- iText 5.0.6 (private => protected)
-
objectList
protected java.util.List<Element> objectList
Deprecated.The resulting list of elements.
-
-
Constructor Detail
-
HTMLWorker
public HTMLWorker(DocListener document)
Deprecated.Creates a new instance of HTMLWorker- Parameters:
document- A class that implementsDocListener
-
HTMLWorker
public HTMLWorker(DocListener document, java.util.Map<java.lang.String,HTMLTagProcessor> tags, StyleSheet style)
Deprecated.Creates a new instance of HTMLWorker- Parameters:
document- A class that implementsDocListenertags- A map containing the supported tagsstyle- A StyleSheet- Since:
- 5.0.6
-
-
Method Detail
-
setSupportedTags
public void setSupportedTags(java.util.Map<java.lang.String,HTMLTagProcessor> tags)
Deprecated.Sets the map with supported tags.- Parameters:
tags-- Since:
- 5.0.6
-
setStyleSheet
public void setStyleSheet(StyleSheet style)
Deprecated.Setter for the StyleSheet- Parameters:
style- the StyleSheet
-
parse
public void parse(java.io.Reader reader) throws java.io.IOExceptionDeprecated.Parses content read from a java.io.Reader object.- Parameters:
reader- the content- Throws:
java.io.IOException
-
startDocument
public void startDocument()
Deprecated.Description copied from interface:SimpleXMLDocHandlerCalled when the document starts to be parsed.- Specified by:
startDocumentin interfaceSimpleXMLDocHandler- See Also:
SimpleXMLDocHandler.startDocument()
-
startElement
public void startElement(java.lang.String tag, java.util.Map<java.lang.String,java.lang.String> attrs)Deprecated.Description copied from interface:SimpleXMLDocHandlerCalled when a start tag is found.- Specified by:
startElementin interfaceSimpleXMLDocHandler- Parameters:
tag- the tag nameattrs- the tag's attributes- See Also:
SimpleXMLDocHandler.startElement(java.lang.String, java.util.Map)
-
text
public void text(java.lang.String content)
Deprecated.Description copied from interface:SimpleXMLDocHandlerCalled when a text element is found.- Specified by:
textin interfaceSimpleXMLDocHandler- Parameters:
content- the text element, probably a fragment.- See Also:
SimpleXMLDocHandler.text(java.lang.String)
-
endElement
public void endElement(java.lang.String tag)
Deprecated.Description copied from interface:SimpleXMLDocHandlerCalled when an end tag is found.- Specified by:
endElementin interfaceSimpleXMLDocHandler- Parameters:
tag- the tag name- See Also:
SimpleXMLDocHandler.endElement(java.lang.String)
-
endDocument
public void endDocument()
Deprecated.Description copied from interface:SimpleXMLDocHandlerCalled after the document is parsed.- Specified by:
endDocumentin interfaceSimpleXMLDocHandler- See Also:
SimpleXMLDocHandler.endDocument()
-
newLine
public void newLine()
Deprecated.Adds a new line to the currentParagraph.- Since:
- 5.0.6
-
carriageReturn
public void carriageReturn() throws DocumentExceptionDeprecated.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
public void pushToStack(Element element)
Deprecated.Pushes an element to the Stack.- Parameters:
element-- Since:
- 5.0.6
-
updateChain
public void updateChain(java.lang.String tag, java.util.Map<java.lang.String,java.lang.String> attrs)Deprecated.Updates the chain with a new tag and new attributes.- Parameters:
tag- the new tagattrs- the corresponding attributes- Since:
- 5.0.6
-
updateChain
public void updateChain(java.lang.String tag)
Deprecated.Updates the chain by removing a tag.- Parameters:
tag- the new tag- Since:
- 5.0.6
-
setProviders
public void setProviders(java.util.Map<java.lang.String,java.lang.Object> providers)
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
public Chunk createChunk(java.lang.String content)
Deprecated.Creates a Chunk using the factory.- Parameters:
content- the content of the chunk- Returns:
- a Chunk with content
- Since:
- 5.0.6
-
createParagraph
public Paragraph createParagraph()
Deprecated.Creates a Paragraph using the factory.- Returns:
- a Paragraph without any content
- Since:
- 5.0.6
-
createList
public List createList(java.lang.String tag)
Deprecated.Creates a List object.- Parameters:
tag- should be "ol" or "ul"- Returns:
- a List object
- Since:
- 5.0.6
-
createListItem
public ListItem createListItem()
Deprecated.Creates a ListItem object.- Returns:
- a ListItem object
- Since:
- 5.0.6
-
createLineSeparator
public LineSeparator createLineSeparator(java.util.Map<java.lang.String,java.lang.String> attrs)
Deprecated.Creates a LineSeparator object.- Parameters:
attrs- properties of the LineSeparator- Returns:
- a LineSeparator object
- Since:
- 5.0.6
-
createImage
public Image createImage(java.util.Map<java.lang.String,java.lang.String> attrs) throws DocumentException, java.io.IOException
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:
DocumentExceptionjava.io.IOException- Since:
- 5.0.6
-
createCell
public CellWrapper createCell(java.lang.String tag)
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
public void processList() throws DocumentExceptionDeprecated.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
public void processListItem() throws DocumentExceptionDeprecated.Looks for the List object on the Stack, and adds the ListItem to the List.- Throws:
DocumentException- Since:
- 5.0.6
-
processImage
public void processImage(Image img, java.util.Map<java.lang.String,java.lang.String> attrs) throws DocumentException
Deprecated.Processes an Image.- Parameters:
img-attrs-- Throws:
DocumentException- Since:
- 5.0.6
-
processTable
public void processTable() throws DocumentExceptionDeprecated.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
public static java.util.List<Element> parseToList(java.io.Reader reader, StyleSheet style) throws java.io.IOException
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:
java.io.IOException
-
parseToList
public static java.util.List<Element> parseToList(java.io.Reader reader, StyleSheet style, java.util.HashMap<java.lang.String,java.lang.Object> providers) throws java.io.IOException
Deprecated.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:
java.io.IOException
-
parseToList
public static java.util.List<Element> parseToList(java.io.Reader reader, StyleSheet style, java.util.Map<java.lang.String,HTMLTagProcessor> tags, java.util.HashMap<java.lang.String,java.lang.Object> providers) throws java.io.IOException
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:
java.io.IOException- Since:
- 5.0.6
-
add
public boolean add(Element element) throws DocumentException
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- See Also:
ElementListener.add(com.itextpdf.text.Element)
-
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 interfaceDocListener- See Also:
DocListener.close()
-
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.- See Also:
DocListener.newPage()
-
open
public void open()
Deprecated.Description copied from interface:DocListenerSignals that theDocumenthas been opened and thatElementscan be added.- Specified by:
openin interfaceDocListener- See Also:
DocListener.open()
-
resetPageCount
public void resetPageCount()
Deprecated.Description copied from interface:DocListenerSets the page number to 0.- Specified by:
resetPageCountin interfaceDocListener- See Also:
DocListener.resetPageCount()
-
setMarginMirroring
public boolean setMarginMirroring(boolean marginMirroring)
Deprecated.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
- See Also:
DocListener.setMarginMirroring(boolean)
-
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- 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)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 - See Also:
DocListener.setMargins(float, float, float, float)
-
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- See Also:
DocListener.setPageCount(int)
-
setPageSize
public boolean setPageSize(Rectangle pageSize)
Deprecated.Description copied from interface:DocListenerSets the pagesize.- Specified by:
setPageSizein interfaceDocListener- Parameters:
pageSize- the new pagesize- Returns:
- a
boolean - See Also:
DocListener.setPageSize(com.itextpdf.text.Rectangle)
-
setInterfaceProps
@Deprecated public void setInterfaceProps(java.util.HashMap<java.lang.String,java.lang.Object> providers)
Deprecated.use setProviders() insteadSets the providers.
-
getInterfaceProps
@Deprecated public java.util.Map<java.lang.String,java.lang.Object> getInterfaceProps()
Deprecated.use getProviders() insteadGets the providers
-
-