Package com.itextpdf.html2pdf
Class HtmlConverter
java.lang.Object
com.itextpdf.html2pdf.HtmlConverter
The HtmlConverter is the class you will use most when converting HTML to PDF. It contains a series of static methods that accept HTML as a
String, File, or InputStream, and convert it to PDF in the form of an OutputStream, File, or a series of iText elements. It's also possible to write to a PdfWriter or PdfDocument instance.
-
Method Summary
Modifier and TypeMethodDescriptionstatic com.itextpdf.layout.DocumentconvertToDocument(InputStream htmlStream, com.itextpdf.kernel.pdf.PdfDocument pdfDocument, ConverterProperties converterProperties) Converts HTML obtained from anInputStreamto objects that will be added to aPdfDocument, using specificConverterProperties, returning aDocumentinstance.static com.itextpdf.layout.DocumentconvertToDocument(InputStream htmlStream, com.itextpdf.kernel.pdf.PdfWriter pdfWriter) Converts HTML obtained from anInputStreamto content that will be written to aPdfWriter, returning aDocumentinstance.static com.itextpdf.layout.DocumentconvertToDocument(InputStream htmlStream, com.itextpdf.kernel.pdf.PdfWriter pdfWriter, ConverterProperties converterProperties) Converts HTML obtained from anInputStreamto content that will be written to aPdfWriter, using specificConverterProperties, returning aDocumentinstance.static com.itextpdf.layout.DocumentconvertToDocument(String html, com.itextpdf.kernel.pdf.PdfDocument pdfDocument, ConverterProperties converterProperties) Converts aStringcontaining HTML to objects that will be added to aPdfDocument, using specificConverterProperties, returning aDocumentinstance.static com.itextpdf.layout.DocumentconvertToDocument(String html, com.itextpdf.kernel.pdf.PdfWriter pdfWriter) Converts aStringcontaining HTML to content that will be written to aPdfWriter, returning aDocumentinstance.static com.itextpdf.layout.DocumentconvertToDocument(String html, com.itextpdf.kernel.pdf.PdfWriter pdfWriter, ConverterProperties converterProperties) Converts aStringcontaining HTML to content that will be written to aPdfWriter, using specificConverterProperties, returning aDocumentinstance.static ListconvertToElements(InputStream htmlStream) static ListconvertToElements(InputStream htmlStream, ConverterProperties converterProperties) Converts HTML obtained from anInputStreamto aListof iText objects (IElementinstances), using specificConverterProperties.static ListconvertToElements(String html) static ListconvertToElements(String html, ConverterProperties converterProperties) Converts aStringcontaining HTML to aListof iText objects (IElementinstances), using specificConverterProperties.static voidconvertToPdf(File htmlFile, File pdfFile) static voidconvertToPdf(File htmlFile, File pdfFile, ConverterProperties converterProperties) static voidconvertToPdf(InputStream htmlStream, com.itextpdf.kernel.pdf.PdfDocument pdfDocument) Converts HTML obtained from anInputStreamto objects that will be added to aPdfDocument.static voidconvertToPdf(InputStream htmlStream, com.itextpdf.kernel.pdf.PdfDocument pdfDocument, ConverterProperties converterProperties) Converts HTML obtained from anInputStreamto objects that will be added to aPdfDocument, using specificConverterProperties.static voidconvertToPdf(InputStream htmlStream, com.itextpdf.kernel.pdf.PdfWriter pdfWriter) Converts HTML obtained from anInputStreamto content that will be written to aPdfWriter.static voidconvertToPdf(InputStream htmlStream, com.itextpdf.kernel.pdf.PdfWriter pdfWriter, ConverterProperties converterProperties) Converts HTML obtained from anInputStreamto content that will be written to aPdfWriter, using specificConverterProperties.static voidconvertToPdf(InputStream htmlStream, OutputStream pdfStream) Converts HTML obtained from anInputStreamto a PDF written to anOutputStream.static voidconvertToPdf(InputStream htmlStream, OutputStream pdfStream, ConverterProperties converterProperties) Converts HTML obtained from anInputStreamto a PDF written to anOutputStream.static voidconvertToPdf(String html, com.itextpdf.kernel.pdf.PdfDocument pdfDocument, ConverterProperties converterProperties) Converts aStringcontaining HTML to objects that will be added to aPdfDocument, using specificConverterProperties.static voidconvertToPdf(String html, com.itextpdf.kernel.pdf.PdfWriter pdfWriter) Converts aStringcontaining HTML to PDF by writing PDF content to aPdfWriterinstance.static voidconvertToPdf(String html, com.itextpdf.kernel.pdf.PdfWriter pdfWriter, ConverterProperties converterProperties) Converts aStringcontaining HTML to PDF by writing PDF content to aPdfWriterinstance, using specificConverterProperties.static voidconvertToPdf(String html, OutputStream pdfStream) Converts aStringcontaining HTML to anOutputStreamcontaining PDF.static voidconvertToPdf(String html, OutputStream pdfStream, ConverterProperties converterProperties) Converts aStringcontaining HTML to anOutputStreamcontaining PDF, using specificConverterProperties.
-
Method Details
-
convertToPdf
Converts aStringcontaining HTML to anOutputStreamcontaining PDF.- Parameters:
-
html- the html in the form of aString -
pdfStream- the PDF as anOutputStream
-
convertToPdf
public static void convertToPdf(String html, OutputStream pdfStream, ConverterProperties converterProperties) Converts aStringcontaining HTML to anOutputStreamcontaining PDF, using specificConverterProperties.- Parameters:
-
html- the html in the form of aString -
pdfStream- the PDF as anOutputStream -
converterProperties- aConverterPropertiesinstance
-
convertToPdf
Converts aStringcontaining HTML to PDF by writing PDF content to aPdfWriterinstance.- Parameters:
-
html- the html in the form of aString -
pdfWriter- thePdfWriterinstance
-
convertToPdf
public static void convertToPdf(String html, com.itextpdf.kernel.pdf.PdfWriter pdfWriter, ConverterProperties converterProperties) Converts aStringcontaining HTML to PDF by writing PDF content to aPdfWriterinstance, using specificConverterProperties.- Parameters:
-
html- the html in the form of aString -
pdfWriter- thePdfWriterinstance -
converterProperties- aConverterPropertiesinstance
-
convertToPdf
public static void convertToPdf(String html, com.itextpdf.kernel.pdf.PdfDocument pdfDocument, ConverterProperties converterProperties) Converts aStringcontaining HTML to objects that will be added to aPdfDocument, using specificConverterProperties.- Parameters:
-
html- the html in the form of aString -
pdfDocument- thePdfDocumentinstance -
converterProperties- aConverterPropertiesinstance
-
convertToPdf
- Parameters:
-
htmlFile- theFilecontaining the source HTML -
pdfFile- theFilecontaining the resulting PDF - Throws:
-
IOException- Signals that an I/O exception has occurred.
-
convertToPdf
public static void convertToPdf(File htmlFile, File pdfFile, ConverterProperties converterProperties) throws IOException - Parameters:
-
htmlFile- theFilecontaining the source HTML -
pdfFile- theFilecontaining the resulting PDF -
converterProperties- aConverterPropertiesinstance - Throws:
-
IOException- Signals that an I/O exception has occurred.
-
convertToPdf
Converts HTML obtained from anInputStreamto a PDF written to anOutputStream.- Parameters:
-
htmlStream- theInputStreamwith the source HTML -
pdfStream- theOutputStreamfor the resulting PDF - Throws:
-
IOException- Signals that an I/O exception has occurred.
-
convertToPdf
public static void convertToPdf(InputStream htmlStream, OutputStream pdfStream, ConverterProperties converterProperties) throws IOException Converts HTML obtained from anInputStreamto a PDF written to anOutputStream.- Parameters:
-
htmlStream- theInputStreamwith the source HTML -
pdfStream- theOutputStreamfor the resulting PDF -
converterProperties- aConverterPropertiesinstance - Throws:
-
IOException- Signals that an I/O exception has occurred.
-
convertToPdf
public static void convertToPdf(InputStream htmlStream, com.itextpdf.kernel.pdf.PdfDocument pdfDocument) throws IOException Converts HTML obtained from anInputStreamto objects that will be added to aPdfDocument.- Parameters:
-
htmlStream- theInputStreamwith the source HTML -
pdfDocument- thePdfDocumentinstance - Throws:
-
IOException- Signals that an I/O exception has occurred.
-
convertToPdf
public static void convertToPdf(InputStream htmlStream, com.itextpdf.kernel.pdf.PdfWriter pdfWriter) throws IOException Converts HTML obtained from anInputStreamto content that will be written to aPdfWriter.- Parameters:
-
htmlStream- theInputStreamwith the source HTML -
pdfWriter- thePdfWritercontaining the resulting PDF - Throws:
-
IOException- Signals that an I/O exception has occurred.
-
convertToPdf
public static void convertToPdf(InputStream htmlStream, com.itextpdf.kernel.pdf.PdfWriter pdfWriter, ConverterProperties converterProperties) throws IOException Converts HTML obtained from anInputStreamto content that will be written to aPdfWriter, using specificConverterProperties.- Parameters:
-
htmlStream- theInputStreamwith the source HTML -
pdfWriter- thePdfWritercontaining the resulting PDF -
converterProperties- aConverterPropertiesinstance - Throws:
-
IOException- Signals that an I/O exception has occurred.
-
convertToPdf
public static void convertToPdf(InputStream htmlStream, com.itextpdf.kernel.pdf.PdfDocument pdfDocument, ConverterProperties converterProperties) throws IOException Converts HTML obtained from anInputStreamto objects that will be added to aPdfDocument, using specificConverterProperties.- Parameters:
-
htmlStream- theInputStreamwith the source HTML -
pdfDocument- thePdfDocumentinstance -
converterProperties- aConverterPropertiesinstance - Throws:
-
IOException- Signals that an I/O exception has occurred.
-
convertToDocument
public static com.itextpdf.layout.Document convertToDocument(String html, com.itextpdf.kernel.pdf.PdfWriter pdfWriter) Converts aStringcontaining HTML to content that will be written to aPdfWriter, returning aDocumentinstance.- Parameters:
-
html- the html in the form of aString -
pdfWriter- thePdfWritercontaining the resulting PDF - Returns:
-
a
Documentinstance
-
convertToDocument
public static com.itextpdf.layout.Document convertToDocument(InputStream htmlStream, com.itextpdf.kernel.pdf.PdfWriter pdfWriter) throws IOException Converts HTML obtained from anInputStreamto content that will be written to aPdfWriter, returning aDocumentinstance.- Parameters:
-
htmlStream- theInputStreamwith the source HTML -
pdfWriter- thePdfWritercontaining the resulting PDF - Returns:
-
a
Documentinstance - Throws:
-
IOException- Signals that an I/O exception has occurred.
-
convertToDocument
public static com.itextpdf.layout.Document convertToDocument(String html, com.itextpdf.kernel.pdf.PdfWriter pdfWriter, ConverterProperties converterProperties) Converts aStringcontaining HTML to content that will be written to aPdfWriter, using specificConverterProperties, returning aDocumentinstance.- Parameters:
-
html- the html in the form of aString -
pdfWriter- the pdf writer -
converterProperties- aConverterPropertiesinstance - Returns:
-
a
Documentinstance
-
convertToDocument
public static com.itextpdf.layout.Document convertToDocument(InputStream htmlStream, com.itextpdf.kernel.pdf.PdfWriter pdfWriter, ConverterProperties converterProperties) throws IOException Converts HTML obtained from anInputStreamto content that will be written to aPdfWriter, using specificConverterProperties, returning aDocumentinstance.- Parameters:
-
htmlStream- the html stream -
pdfWriter- the pdf writer -
converterProperties- aConverterPropertiesinstance - Returns:
-
a
Documentinstance - Throws:
-
IOException- Signals that an I/O exception has occurred.
-
convertToDocument
public static com.itextpdf.layout.Document convertToDocument(String html, com.itextpdf.kernel.pdf.PdfDocument pdfDocument, ConverterProperties converterProperties) Converts aStringcontaining HTML to objects that will be added to aPdfDocument, using specificConverterProperties, returning aDocumentinstance.- Parameters:
-
html- the html in the form of aString -
pdfDocument- thePdfDocumentinstance -
converterProperties- aConverterPropertiesinstance - Returns:
-
a
Documentinstance
-
convertToDocument
public static com.itextpdf.layout.Document convertToDocument(InputStream htmlStream, com.itextpdf.kernel.pdf.PdfDocument pdfDocument, ConverterProperties converterProperties) throws IOException Converts HTML obtained from anInputStreamto objects that will be added to aPdfDocument, using specificConverterProperties, returning aDocumentinstance.- Parameters:
-
htmlStream- theInputStreamwith the source HTML -
pdfDocument- thePdfDocumentinstance -
converterProperties- aConverterPropertiesinstance - Returns:
-
a
Documentinstance - Throws:
-
IOException- Signals that an I/O exception has occurred.
-
convertToElements
- Parameters:
-
html- the html in the form of aString - Returns:
- a list of iText building blocks
-
convertToElements
- Parameters:
-
htmlStream- theInputStreamwith the source HTML - Returns:
- a list of iText building blocks
- Throws:
-
IOException- Signals that an I/O exception has occurred.
-
convertToElements
Converts aStringcontaining HTML to aListof iText objects (IElementinstances), using specificConverterProperties.- Parameters:
-
html- the html in the form of aString -
converterProperties- aConverterPropertiesinstance - Returns:
- a list of iText building blocks
-
convertToElements
public static ListconvertToElements (InputStream htmlStream, ConverterProperties converterProperties) throws IOException Converts HTML obtained from anInputStreamto aListof iText objects (IElementinstances), using specificConverterProperties.- Parameters:
-
htmlStream- theInputStreamwith the source HTML -
converterProperties- aConverterPropertiesinstance - Returns:
- a list of iText building blocks
- Throws:
-
IOException- Signals that an I/O exception has occurred.
-