HTML to PDF
Paste HTML and CSS, preview it, and save it as a paged PDF in A4, Letter or Legal size. Pages are saved as images, and the tool takes HTML code, not web addresses.
About the HTML to PDF
This tool converts HTML code that you paste into the editor (not a web address) into a PDF. Your HTML is rendered in a hidden frame at the width of the chosen page, so A4 portrait content is laid out about 794 pixels wide, and the html2canvas library draws it page by page. Each page image is placed into the PDF by jsPDF with a 10 mm margin at the top and bottom, and page breaks are moved to an empty band where one exists, so lines of text are not cut in half.
Styles in a <style> block, in style attributes and in linked stylesheets are applied. Before rendering, the HTML is sanitised: <script> elements, inline event handlers such as onclick and other active content are removed, so nothing in your code runs, and content that a script would normally build will not appear. Images and fonts that your HTML loads from other websites are fetched by your browser; images from servers that do not allow cross-origin access are left out of the PDF.
It suits HTML you have written or generated yourself: an invoice or receipt template, a report produced by a script, an email layout, or a styled table you want to send as a PDF. For example, paste a simple invoice template, check it with Preview, choose A4 and Portrait, and click Convert to PDF; the file downloads as converted.pdf. Because the pages are images, the text in the PDF cannot be selected or searched. To tidy messy markup before converting, try the HTML Beautifier, and to test HTML and CSS interactively, the Live Code Editor.
How to use the HTML to PDF
- 1
Paste your HTML
Replace the sample in the HTML Editor with your own code, including any <style> block.
- 2
Preview it
Click Preview to see how the HTML renders. Scripts do not run in the preview either.
- 3
Choose page size and orientation
Select A4, Letter or Legal, and Portrait or Landscape.
- 4
Convert to PDF
Click Convert to PDF. The label shows which page is being rendered, and the PDF downloads automatically when it is done.
What it can do
Three paper sizes, two orientations
A4, Letter and Legal in portrait or landscape; the content is laid out at the width of the chosen page.
Multi-page output
Long content flows onto as many pages as needed, with breaks placed in empty space where possible.
CSS support through the browser
Layout, including flexbox, grid and tables, is calculated by your browser before the page is drawn.
Scripts removed for safety
The HTML is sanitised with DOMPurify, so pasted code cannot run scripts on this site.
Limitations
- Only pasted HTML is converted; the tool cannot fetch or convert a page from a URL.
- Pages are saved as images, so text in the PDF is not selectable or searchable, and links are not clickable.
- JavaScript is removed, so charts or content built by scripts will be missing.
- html2canvas does not draw every CSS feature; for example filters, blend modes, object-fit and vertical writing modes are not reproduced.
- External images appear only if their server allows cross-origin loading, and slow resources may not finish loading in time.
Privacy
Your HTML is rendered and converted in your browser and is not uploaded to FlexyPdf’s servers. If it references images, stylesheets or fonts on other websites, your browser requests those files from those sites.
Frequently asked questions
Can I convert a website by entering its URL?
No. The tool only converts HTML you paste in. To capture a live web page, use your browser’s own Print dialog and choose Save as PDF, which also keeps the text selectable.
Why can’t I select text in the PDF?
The HTML is drawn onto a canvas and each page is stored as a JPEG image. That makes the result look like the rendered HTML in any PDF reader, but the text is part of the image.
Why is an image from my HTML missing?
Images on other websites can only be drawn if their server allows cross-origin requests. Host the image yourself, or embed it as a data URI (data:image/png;base64,...), and it will be included.
How do I control where pages break?
The tool puts each break in an empty horizontal band near the bottom of the page when it finds one. CSS page-break rules are not read, so leave some vertical space between sections if you want breaks in particular places.
Ratings & Reviews
Rate HTML to PDF
Help others by sharing your experience. Your rating is shown without your name.
More PDF Tools
View all →PDF Editor
Add text, signatures, shapes and images to a PDF, and rotate, add or delete pages
JPG to PDF
Turn JPG and PNG images into one PDF, one image per page
PDF to Word
Extract the text of a PDF into an editable Word (.docx) document
Word to PDF
Convert a .docx document into a PDF with a simple, clean layout