pdfHTML – convert HTML into rich, smart PDF documents

Are you in need of converting HTML to PDF? In this post, we used Google Play as an example to showcase our advanced HTML conversion hero, pdfHTML, versus a competitor’s HTML converter.

19th April 2019
molly.chen

Are you in need of converting HTML to PDF? In this post, we used Google Play as an example to showcase our advanced HTML conversion hero, pdfHTML, versus a competitor’s HTML converter.

 

Below is the original web page we’re using to test iText 7 pdfHTML:

Original Google Play web page for comparison
Google Play example

Here is the result of iText 7’s pdfHTML conversion, versus a competitor’s efforts:

Comparison of pdfHTML conversion versus a competitor

With iText 7’s pdfHTML conversion, the table formatting was preserved, and all the images and data were perfectly aligned as they should appear. 

But that's not all.  pdfHTML also provides a convenient and simple API (application programming interface) which allows you to convert HTML files straight to PDF files, or to a list of iText elements. This gives you full control over how to parse and insert the HTML elements. By re-using the structural information from HTML to easily create PDF/A, PDF/UA, or Tagged PDFs, pdfHTML provides the engine to convert HTML to PDF, and the results are well-formatted, well-structured PDF documents. There is no need to know the technical details of the PDF format, pdfHTML utilizes semantic and structural information already present in the HTML.

Key Features

Core capabilities development icon

Leverage HTML Flexibility in PDF

pdfHTML converts static HTML5 and CSS3 to PDF seamlessly, and the conversion is customizable, dynamic and simple through an easy to use API.

Core capabilities development icon

Compliant with PDF Standards

pdfHTML allows you to create PDF/A, PDF/UA*, and tagged PDFs that are standards compliant.

Core capabilities development icon

Conversion Options

pdfHTML converts a full document to PDF directly, and any HTML snippet to “iText building blocks” (for example, transforming an HTML rich text paragraph into an iText Paragraph object).

Core capabilities development icon

Customizable

Using pdfHTML, you can add dynamic content to your PDF such as barcodes. Furthermore, you can leverage converter properties and custom processing of tags to fine-tune your conversion.

*Under Section 508 of the Rehabilition Act of 1973 in ICT Standards and Guidelines, PDF/UA is a requirement for all PDF files.

Usage example

The following code demonstrates how to generate a PDF from an HTML source:

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.OpenOrCreate))
    {
        ConverterProperties converterProperties = new ConverterProperties();
        HtmlConverter.ConvertToPdf(htmlSource, pdfDest, converterProperties);
    }
  }

 

Want to see more? Download the full pdfHTML ebook here! 



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