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.Document
convertToDocument
(InputStream htmlStream, com.itextpdf.kernel.pdf.PdfDocument pdfDocument, ConverterProperties converterProperties) Converts HTML obtained from anInputStream
to objects that will be added to aPdfDocument
, using specificConverterProperties
, returning aDocument
instance.static com.itextpdf.layout.Document
convertToDocument
(InputStream htmlStream, com.itextpdf.kernel.pdf.PdfWriter pdfWriter) Converts HTML obtained from anInputStream
to content that will be written to aPdfWriter
, returning aDocument
instance.static com.itextpdf.layout.Document
convertToDocument
(InputStream htmlStream, com.itextpdf.kernel.pdf.PdfWriter pdfWriter, ConverterProperties converterProperties) Converts HTML obtained from anInputStream
to content that will be written to aPdfWriter
, using specificConverterProperties
, returning aDocument
instance.static com.itextpdf.layout.Document
convertToDocument
(String html, com.itextpdf.kernel.pdf.PdfDocument pdfDocument, ConverterProperties converterProperties) Converts aString
containing HTML to objects that will be added to aPdfDocument
, using specificConverterProperties
, returning aDocument
instance.static com.itextpdf.layout.Document
convertToDocument
(String html, com.itextpdf.kernel.pdf.PdfWriter pdfWriter) Converts aString
containing HTML to content that will be written to aPdfWriter
, returning aDocument
instance.static com.itextpdf.layout.Document
convertToDocument
(String html, com.itextpdf.kernel.pdf.PdfWriter pdfWriter, ConverterProperties converterProperties) Converts aString
containing HTML to content that will be written to aPdfWriter
, using specificConverterProperties
, returning aDocument
instance.static List
convertToElements
(InputStream htmlStream) static List
convertToElements
(InputStream htmlStream, ConverterProperties converterProperties) Converts HTML obtained from anInputStream
to aList
of iText objects (IElement
instances), using specificConverterProperties
.static List
convertToElements
(String html) static List
convertToElements
(String html, ConverterProperties converterProperties) Converts aString
containing HTML to aList
of iText objects (IElement
instances), using specificConverterProperties
.static void
convertToPdf
(File htmlFile, File pdfFile) static void
convertToPdf
(File htmlFile, File pdfFile, ConverterProperties converterProperties) static void
convertToPdf
(InputStream htmlStream, com.itextpdf.kernel.pdf.PdfDocument pdfDocument) Converts HTML obtained from anInputStream
to objects that will be added to aPdfDocument
.static void
convertToPdf
(InputStream htmlStream, com.itextpdf.kernel.pdf.PdfDocument pdfDocument, ConverterProperties converterProperties) Converts HTML obtained from anInputStream
to objects that will be added to aPdfDocument
, using specificConverterProperties
.static void
convertToPdf
(InputStream htmlStream, com.itextpdf.kernel.pdf.PdfWriter pdfWriter) Converts HTML obtained from anInputStream
to content that will be written to aPdfWriter
.static void
convertToPdf
(InputStream htmlStream, com.itextpdf.kernel.pdf.PdfWriter pdfWriter, ConverterProperties converterProperties) Converts HTML obtained from anInputStream
to content that will be written to aPdfWriter
, using specificConverterProperties
.static void
convertToPdf
(InputStream htmlStream, OutputStream pdfStream) Converts HTML obtained from anInputStream
to a PDF written to anOutputStream
.static void
convertToPdf
(InputStream htmlStream, OutputStream pdfStream, ConverterProperties converterProperties) Converts HTML obtained from anInputStream
to a PDF written to anOutputStream
.static void
convertToPdf
(String html, com.itextpdf.kernel.pdf.PdfDocument pdfDocument, ConverterProperties converterProperties) Converts aString
containing HTML to objects that will be added to aPdfDocument
, using specificConverterProperties
.static void
convertToPdf
(String html, com.itextpdf.kernel.pdf.PdfWriter pdfWriter) Converts aString
containing HTML to PDF by writing PDF content to aPdfWriter
instance.static void
convertToPdf
(String html, com.itextpdf.kernel.pdf.PdfWriter pdfWriter, ConverterProperties converterProperties) Converts aString
containing HTML to PDF by writing PDF content to aPdfWriter
instance, using specificConverterProperties
.static void
convertToPdf
(String html, OutputStream pdfStream) Converts aString
containing HTML to anOutputStream
containing PDF.static void
convertToPdf
(String html, OutputStream pdfStream, ConverterProperties converterProperties) Converts aString
containing HTML to anOutputStream
containing PDF, using specificConverterProperties
.
-
Method Details
-
convertToPdf
Converts aString
containing HTML to anOutputStream
containing 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 aString
containing HTML to anOutputStream
containing PDF, using specificConverterProperties
.- Parameters:
-
html
- the html in the form of aString
-
pdfStream
- the PDF as anOutputStream
-
converterProperties
- aConverterProperties
instance
-
convertToPdf
Converts aString
containing HTML to PDF by writing PDF content to aPdfWriter
instance.- Parameters:
-
html
- the html in the form of aString
-
pdfWriter
- thePdfWriter
instance
-
convertToPdf
public static void convertToPdf(String html, com.itextpdf.kernel.pdf.PdfWriter pdfWriter, ConverterProperties converterProperties) Converts aString
containing HTML to PDF by writing PDF content to aPdfWriter
instance, using specificConverterProperties
.- Parameters:
-
html
- the html in the form of aString
-
pdfWriter
- thePdfWriter
instance -
converterProperties
- aConverterProperties
instance
-
convertToPdf
public static void convertToPdf(String html, com.itextpdf.kernel.pdf.PdfDocument pdfDocument, ConverterProperties converterProperties) Converts aString
containing HTML to objects that will be added to aPdfDocument
, using specificConverterProperties
.- Parameters:
-
html
- the html in the form of aString
-
pdfDocument
- thePdfDocument
instance -
converterProperties
- aConverterProperties
instance
-
convertToPdf
- Parameters:
-
htmlFile
- theFile
containing the source HTML -
pdfFile
- theFile
containing 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
- theFile
containing the source HTML -
pdfFile
- theFile
containing the resulting PDF -
converterProperties
- aConverterProperties
instance - Throws:
-
IOException
- Signals that an I/O exception has occurred.
-
convertToPdf
Converts HTML obtained from anInputStream
to a PDF written to anOutputStream
.- Parameters:
-
htmlStream
- theInputStream
with the source HTML -
pdfStream
- theOutputStream
for 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 anInputStream
to a PDF written to anOutputStream
.- Parameters:
-
htmlStream
- theInputStream
with the source HTML -
pdfStream
- theOutputStream
for the resulting PDF -
converterProperties
- aConverterProperties
instance - 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 anInputStream
to objects that will be added to aPdfDocument
.- Parameters:
-
htmlStream
- theInputStream
with the source HTML -
pdfDocument
- thePdfDocument
instance - 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 anInputStream
to content that will be written to aPdfWriter
.- Parameters:
-
htmlStream
- theInputStream
with the source HTML -
pdfWriter
- thePdfWriter
containing 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 anInputStream
to content that will be written to aPdfWriter
, using specificConverterProperties
.- Parameters:
-
htmlStream
- theInputStream
with the source HTML -
pdfWriter
- thePdfWriter
containing the resulting PDF -
converterProperties
- aConverterProperties
instance - 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 anInputStream
to objects that will be added to aPdfDocument
, using specificConverterProperties
.- Parameters:
-
htmlStream
- theInputStream
with the source HTML -
pdfDocument
- thePdfDocument
instance -
converterProperties
- aConverterProperties
instance - 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 aString
containing HTML to content that will be written to aPdfWriter
, returning aDocument
instance.- Parameters:
-
html
- the html in the form of aString
-
pdfWriter
- thePdfWriter
containing the resulting PDF - Returns:
-
a
Document
instance
-
convertToDocument
public static com.itextpdf.layout.Document convertToDocument(InputStream htmlStream, com.itextpdf.kernel.pdf.PdfWriter pdfWriter) throws IOException Converts HTML obtained from anInputStream
to content that will be written to aPdfWriter
, returning aDocument
instance.- Parameters:
-
htmlStream
- theInputStream
with the source HTML -
pdfWriter
- thePdfWriter
containing the resulting PDF - Returns:
-
a
Document
instance - 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 aString
containing HTML to content that will be written to aPdfWriter
, using specificConverterProperties
, returning aDocument
instance.- Parameters:
-
html
- the html in the form of aString
-
pdfWriter
- the pdf writer -
converterProperties
- aConverterProperties
instance - Returns:
-
a
Document
instance
-
convertToDocument
public static com.itextpdf.layout.Document convertToDocument(InputStream htmlStream, com.itextpdf.kernel.pdf.PdfWriter pdfWriter, ConverterProperties converterProperties) throws IOException Converts HTML obtained from anInputStream
to content that will be written to aPdfWriter
, using specificConverterProperties
, returning aDocument
instance.- Parameters:
-
htmlStream
- the html stream -
pdfWriter
- the pdf writer -
converterProperties
- aConverterProperties
instance - Returns:
-
a
Document
instance - 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 aString
containing HTML to objects that will be added to aPdfDocument
, using specificConverterProperties
, returning aDocument
instance.- Parameters:
-
html
- the html in the form of aString
-
pdfDocument
- thePdfDocument
instance -
converterProperties
- aConverterProperties
instance - Returns:
-
a
Document
instance
-
convertToDocument
public static com.itextpdf.layout.Document convertToDocument(InputStream htmlStream, com.itextpdf.kernel.pdf.PdfDocument pdfDocument, ConverterProperties converterProperties) throws IOException Converts HTML obtained from anInputStream
to objects that will be added to aPdfDocument
, using specificConverterProperties
, returning aDocument
instance.- Parameters:
-
htmlStream
- theInputStream
with the source HTML -
pdfDocument
- thePdfDocument
instance -
converterProperties
- aConverterProperties
instance - Returns:
-
a
Document
instance - 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
- theInputStream
with the source HTML - Returns:
- a list of iText building blocks
- Throws:
-
IOException
- Signals that an I/O exception has occurred.
-
convertToElements
Converts aString
containing HTML to aList
of iText objects (IElement
instances), using specificConverterProperties
.- Parameters:
-
html
- the html in the form of aString
-
converterProperties
- aConverterProperties
instance - Returns:
- a list of iText building blocks
-
convertToElements
public static ListconvertToElements (InputStream htmlStream, ConverterProperties converterProperties) throws IOException Converts HTML obtained from anInputStream
to aList
of iText objects (IElement
instances), using specificConverterProperties
.- Parameters:
-
htmlStream
- theInputStream
with the source HTML -
converterProperties
- aConverterProperties
instance - Returns:
- a list of iText building blocks
- Throws:
-
IOException
- Signals that an I/O exception has occurred.
-