How to Convert an HTML File to PDF
- html to pdf
- convert
- pro
Short answer: open HTML to PDF on ilovspdfs, choose an .html file, pick the page size (A4, US Letter or US Legal), orientation and margins (Normal, Narrow or None), and download the PDF. A headless browser renders it, so CSS, tables and lists look as they would in a browser. Scripts do not run and nothing outside the file is fetched, so images and styles must be inside the file. This is one of the eight Pro tools that run on an ilovspdfs server: the file is sent over HTTPS, processed in memory and never stored. Pro costs US$6 a month or US$48 a year, and cloud files can be up to 4 MB.
How do I convert an HTML file to PDF?
- Open HTML to PDF with a Pro account.
- Choose the .html file (up to 4 MB).
- Pick Page size, orientation and Margins.
- Download the PDF.
Why are my images or styles missing?
Because they are linked rather than embedded. For safety the renderer fetches nothing from the network, which stops an uploaded file from making the server contact other sites. Put styles in a style element in the page and images in data: URIs, and they appear. Most static site generators and email builders have an "inline everything" option.
Can I give it a web address instead?
No. It renders a file you upload, with no network access. To convert a live web page, use your browser's Print, Save as PDF, or save the page as a single file first.
Does JavaScript run?
No. Content that a script builds after the page loads (charts drawn by a chart library, for example) will not appear. Render those to images or static HTML first.
Good uses
- Invoices and receipts generated as HTML by your own system.
- Reports from data tools that export a single HTML file.
- Documentation pages saved for offline reading.
After converting, merge the PDFs, number the pages or compress them, free in your browser.
Questions
How do I convert HTML to PDF and keep the CSS?
Put the CSS in a style element inside the HTML file and convert it with HTML to PDF on ilovspdfs; linked stylesheets are not fetched.
Can I convert a URL to PDF?
Not with this tool, which renders an uploaded file with no network access. Use your browser's Print to PDF for a live page.
Which page sizes are available?
A4, US Letter and US Legal, in portrait or landscape, with Normal, Narrow or no margins.
HTML to PDF
Render an HTML file to PDF with a real browser engine.