public class XMLWorkerHelper extends Object
Modifier and Type | Method and Description |
---|---|
static CssFile |
getCSS(InputStream in) |
CssFile |
getDefaultCSS() |
CSSResolver |
getDefaultCssResolver(boolean addDefaultCss)
Get a CSSResolver implementation.
|
protected TagProcessorFactory |
getDefaultTagProcessorFactory()
Retrieves the default factory for processing HTML tags from Tags.getHtmlTagProcessorFactory() .
|
static XMLWorkerHelper |
getInstance()
Get a Singleton XMLWorkerHelper
|
static ElementList |
parseToElementList(String html, String css)
Parses an HTML string and a string containing CSS into a list of Element objects.
|
void |
parseXHtml(ElementHandler d, InputStream in, Charset charset) |
void |
parseXHtml(ElementHandler d, Reader in)
Parses the xml data in the given reader and sends created Element s to the defined ElementHandler.
This method configures the XMLWorker and XMLParser to parse (X)HTML/CSS and accept unknown tags. |
void |
parseXHtml(PdfWriter writer, Document doc, InputStream in) |
void |
parseXHtml(PdfWriter writer, Document doc, InputStream in, Charset charset) |
void |
parseXHtml(PdfWriter writer, Document doc, InputStream in, Charset charset, FontProvider fontProvider) |
void |
parseXHtml(PdfWriter writer, Document doc, InputStream in, InputStream inCssFile) |
void |
parseXHtml(PdfWriter writer, Document doc, InputStream in, InputStream inCssFile, Charset charset) |
void |
parseXHtml(PdfWriter writer, Document doc, InputStream in, InputStream inCssFile, Charset charset, FontProvider fontProvider) |
void |
parseXHtml(PdfWriter writer, Document doc, InputStream in, InputStream inCssFile, Charset charset, FontProvider fontProvider, String resourcesRootPath) |
void |
parseXHtml(PdfWriter writer, Document doc, InputStream in, InputStream inCssFile, FontProvider fontProvider) |
void |
parseXHtml(PdfWriter writer, Document doc, Reader in)
Parses the xml data.
|
public static XMLWorkerHelper getInstance()
public static CssFile getCSS(InputStream in)
public CssFile getDefaultCSS()
public void parseXHtml(ElementHandler d, Reader in) throws IOException
Element
s to the defined ElementHandler.
d
- the handler
in
- the reader
IOException
- thrown when something went wrong with the IO
public void parseXHtml(PdfWriter writer, Document doc, Reader in) throws IOException
writer
- the PdfWriter
doc
- the Document
in
- the reader
IOException
- thrown when something went wrong with the IO
public void parseXHtml(PdfWriter writer, Document doc, InputStream in) throws IOException
writer
- the writer to use
doc
- the document to use
in
- the InputStream
of the XHTML source.
IOException
- if the InputStream
could not be read.
public void parseXHtml(PdfWriter writer, Document doc, InputStream in, Charset charset, FontProvider fontProvider) throws IOException
IOException
public void parseXHtml(PdfWriter writer, Document doc, InputStream in, Charset charset) throws IOException
writer
- the writer to use
doc
- the document to use
in
- the InputStream
of the XHTML source.
charset
- the charset to use
IOException
- if the InputStream
could not be read.
public void parseXHtml(PdfWriter writer, Document doc, InputStream in, InputStream inCssFile, Charset charset, FontProvider fontProvider) throws IOException
writer
- the writer to use
doc
- the document to use
in
- the InputStream
of the XHTML source.
in
- the CssFiles
of the css files.
charset
- the charset to use
IOException
- if the InputStream
could not be read.
public void parseXHtml(PdfWriter writer, Document doc, InputStream in, InputStream inCssFile, Charset charset, FontProvider fontProvider, String resourcesRootPath) throws IOException
writer
- the writer to use
doc
- the document to use
in
- the InputStream
of the XHTML source.
in
- the CssFiles
of the css files.
charset
- the charset to use
resourcesRootPath
- defines the root path to find resources in case they are defined in html with relative paths (e.g. images)
IOException
- if the InputStream
could not be read.
public void parseXHtml(PdfWriter writer, Document doc, InputStream in, InputStream inCssFile) throws IOException
IOException
public void parseXHtml(PdfWriter writer, Document doc, InputStream in, InputStream inCssFile, FontProvider fontProvider) throws IOException
IOException
public void parseXHtml(PdfWriter writer, Document doc, InputStream in, InputStream inCssFile, Charset charset) throws IOException
IOException
public void parseXHtml(ElementHandler d, InputStream in, Charset charset) throws IOException
d
- the ElementHandler
in
- the InputStream
charset
- the charset to use
IOException
- if something went seriously wrong with IO.
public CSSResolver getDefaultCssResolver(boolean addDefaultCss)
addDefaultCss
- true if the defaultCss should already be added.
protected TagProcessorFactory getDefaultTagProcessorFactory()
Tags.getHtmlTagProcessorFactory()
. On subsequent calls the same TagProcessorFactory
is returned every time.
DefaultTagProcessorFactory that maps HTML tags to TagProcessor
s
-
parseToElementList
public static ElementList parseToElementList(String html,
String css)
throws IOException
Parses an HTML string and a string containing CSS into a list of Element objects. The FontProvider will be obtained from iText's FontFactory object.
- Parameters:
-
html
- a String containing an XHTML snippet
-
css
- a String containing CSS
- Returns:
-
an ElementList instance
- Throws:
-
IOException
Copyright © 1998–2018. All rights reserved.