pdfHTML

Intro

iText pdfHTML

pdfHTML is an iText Core add-on for Java and C# (.NET) that allows you to easily convert HTML and CSS into standards compliant PDFs that are accessible, searchable and usable for indexing. 

How it works

With just few lines of code you can use pdfHTML to get great results in no time. This code sample demonstrates how to use pdfHTML to convert a source HTML file (input.html) into a PDF (output.pdf). Click the button in the code window below to switch between the Java and C# examples.

1
2
3
4
5
6
7
8
9
public static void main() throws IOException {
        // IO
        File htmlSource = new File("input.html");
        File pdfDest = new File("output.pdf");
         // pdfHTML specific code
        ConverterProperties converterProperties = new ConverterProperties();
        HtmlConverter.convertToPdf(new FileInputStream(htmlSource), 
       new FileOutputStream(pdfDest), converterProperties);
    }
1
2
3
4
5
6
7
8
9
static void Main(string[] args)
  {
    using (FileStream htmlSource = File.Open("input.html", FileMode.Open))
    using (FileStream pdfDest = File.Open("output.pdf", FileMode.Create))
    {
        ConverterProperties converterProperties = new ConverterProperties();
        HtmlConverter.ConvertToPdf(htmlSource, pdfDest, converterProperties);
    }
  }

 

Below you can see an example of pdfHTML in action; using it to convert a web page into a PDF.

 

The original web page

HTML to PDF example input file

After the pdfHTML conversion

HTML to PDF example output

Benefits

Why use iText pdfHTML?

In addition to simply converting HTML to PDF, you can also use pdfHTML to generate well-formatted, well-structured PDF documents such as reports, invoices etc. using HTML as a template format. You can define styling with CSS and pdfHTML provides the engine for PDF conversion.

It re-uses the structural information from the HTML to easily create PDF/A, PDF/UA, or Tagged PDFs. There is no need to know the technical details of the PDF format. pdfHTML utilizes semantic and structural information already present in the HTML and CSS and maps them to iText objects and styles.

pdfHTML convert HTML to PDF pdfHTML provides the engine to convert HTML to PDF
Easily integrates with HTML tools

By using HTML and CSS to layout and style your document, you can leverage your existing HTML and CSS skills to create PDFs. This add-on easily integrates with HTML tools.

pdfHTML convert HTML to PDF pdfHTML provides the engine to convert HTML to PDF
Out of the box and customized options for HTML to PDF conversion.

The HTML elements are already mapped to iText elements based on HTML5 and CSS3. To customize, you simply add your own handlers to the pdfHTML framework.

pdfHTML convert HTML to PDF pdfHTML provides the engine to convert HTML to PDF
Create a structured PDF document

Convert HTML to PDF with pdfHTML and use the structural and semantic information from HTML to create standards-compliant PDF documents like PDF/A, PDF/UA or Tagged PDFs. 

Key features

Core capabilities of iText pdfHTML

pdfHTML provides a convenience API (Java/.NET) which allows you to convert HTML to PDF files or to a list of iText elements. This gives you full control over how to parse and insert the HTML elements.

When using pdfHTML to convert HTML to PDF you will realize another great advantage. Semantic and structural information contained in the HTML files is an excellent source for pdfHTML to convert the HTML files into rich, smart PDF documents.

iText
Leverage HTML flexibility in PDF

  • Convert static HTML5 and CSS3 to PDF
  • The conversion is customizable, dynamic and simple through an easy to use API.
  • SVG support

iText
Conversion options

  • Convert a full document to PDF directly.
  • Convert an HTML snippet to "iText building blocks", e.g. an HTML rich text paragraph into an iText Paragraph object.

iText
Customizable

  • Add dynamic content to your PDF such as barcodes.
  • Leverage converter properties and custom processing of tags to fine-tune your conversion.
Contact

Still have questions? 

We're happy to answer your questions. Reach out to us and we'll get back to you shortly.

Contact us
Stay updated

Join 11,000+ subscribers and become an iText PDF expert by staying up to date with our new products, updates, tips, technical solutions and happenings.

Subscribe Now