How to convert an HTML table to PDF?

I want the PDF to look like the HTML in the browser. Why doesn't it?

5th November 2015

I have an HTML file that looks like this when I render it in a browser:

HTML input

When I export the String with this HTML to PDF using a Paragraph object, I get the following output:

HTML output

This is not what I want. I want the PDF to look like the HTML in the browser.

Posted on StackOverflow on Jul 2, 2014 by user3152748

Please take a look at the examples ParseHtmlTable1 and ParseHtmlTable2. They create the following PDFs: html_table_1.pdf and html_table_2.pdf.

The table is created like this:

StringBuilder sb = new StringBuilder();


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