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