Skip to content
Back to all articles
File Convert7 min readSeptember 30, 2026

How to Convert HTML to PDF (and Why Some Pages Break)

How HTML-to-PDF conversion works, why scripts, web fonts and complex CSS cause trouble, and how to prepare an HTML file so the PDF comes out clean.

How to Convert HTML to PDF (and Why Some Pages Break) article
In this guide
  1. HTML and PDF: two different ideas of a page
  2. How to convert an HTML file to PDF
  3. What converts well, and what does not
  4. Preparing an HTML file for a clean PDF
  5. When a screenshot is the better option
  6. Common uses
  7. Writing in Markdown? Skip HTML entirely
  8. After converting: tidy, combine and protect
  9. Troubleshooting
  10. Frequently asked questions

Sooner or later, most people who work with the web need a PDF of something that only exists as HTML. A developer wants to send a client the email template they built. A support team wants to archive a help article exactly as it looked on the day a customer read it. A student has lecture notes exported from a note-taking app as a folder of .html files. A small business has invoices generated by its shop software as web pages, and the accountant wants PDFs.

HTML and PDF are built for opposite jobs. HTML flows to fit whatever screen it is on; PDF fixes everything onto pages of a set size. Converting between them is easy for simple pages and surprisingly fiddly for complex ones. This guide explains how the conversion works, why some pages come out perfectly and others do not, and how to prepare a file so the PDF looks the way you expect.

HTML and PDF: two different ideas of a page

A web page has no pages. It is one long, flexible column that reflows when you resize the window, loads images and fonts from wherever it is told to, and often changes itself with JavaScript after it arrives. A PDF is the opposite: a fixed sequence of pages, each with every letter and image in an exact position.

Converting HTML to PDF means taking that flexible content and deciding, once and for all, where each page ends. The converter reads the structure of the document, meaning the headings, paragraphs, lists, tables and images, and lays it out onto pages of a fixed size. The clearer that structure is, the better the result.

How to convert an HTML file to PDF

  1. Get the page as a file. If it is on a website, open it in your browser and use Save Page As, choosing "Web page, HTML only" or "Web page, complete". If it is an export or a template, you already have the .html or .htm file.
  2. Open HTML to PDF and choose the file. Files up to 100 MB are accepted.
  3. Convert. The file is converted on our server by LibreOffice, which reads the HTML structure and lays it out as PDF pages.
  4. Download and check the PDF, paying attention to images, tables and anything that was styled heavily.

The file is sent over HTTPS and deleted from the server as soon as the PDF is returned. The tool converts the file you upload; it does not visit websites or log in anywhere on your behalf.

What converts well, and what does not

Being honest about the limits saves a lot of frustration. The converter reads HTML the way a document program would, not the way a modern browser does.

Converts wellMay not come through
Headings, paragraphs and listsContent added by JavaScript after the page loads
Tables with a clear structureComplex CSS layouts such as grids and flexbox columns
Images embedded in the file or saved alongside itImages and fonts loaded from other servers
Bold, italic, links and basic coloursSticky headers, animations, pop-ups and videos
Simple one-column layoutsPages that need you to be logged in

The pattern is simple: static, document-like pages convert beautifully, while app-like pages that build themselves in the browser do not. A help article, a report or an email template is a great candidate. A dashboard or a social media feed is not.

Preparing an HTML file for a clean PDF

A few minutes of preparation makes a big difference, especially if you control the HTML.

  • Keep the layout to one column. Sidebars and multi-column grids are the most common cause of odd results. Hide them or move their content below the main text.
  • Embed or bundle images. Images referenced by a full web address may not load during conversion. Saving the page as "complete" keeps images in a folder next to the file, and images embedded as data URIs always travel with the HTML.
  • Use real HTML tables for tabular data, rather than rows of styled divs. A table converts into a table; divs only look like one in a browser.
  • Remove the clutter. Cookie banners, navigation menus, share buttons and footers look strange on paper. Delete them from the saved file before converting.
  • Use web-safe fonts such as Arial, Georgia or Times New Roman, or accept that custom web fonts may be replaced by a similar font.
  • Set sensible widths. Fixed widths wider than a page, such as a 1400-pixel container, can squeeze content. Percentages or a max-width around 800 pixels behave better.

When a screenshot is the better option

Sometimes you do not need a document; you need a record of how something looked. A pixel-perfect capture of a live page, with its layout, colours and ads exactly as a visitor saw them, is better done as a screenshot than a conversion.

The Website Screenshot Generator captures a live URL as an image, including pages that rely on JavaScript. If you need that capture as a PDF, a screenshot can then be placed into a PDF. The trade-off is that text in a screenshot is part of an image, so it cannot be searched or copied. For documents people will read and search, convert the HTML; for evidence of what a page looked like, take a screenshot.

Common uses

Email templates. Designers and marketers often need to share an HTML email with someone who will only review a PDF. Emails are usually built with simple tables and inline styles, which convert well.

Documentation and help articles. Converting help pages to PDF gives customers an offline copy and gives you an archive of what the instructions said on a given date.

Reports exported as HTML. Many analytics, testing and accounting tools export reports as HTML. Converting them to PDF makes them easy to attach, print and file.

Notes and knowledge bases. Note apps and wikis often export to HTML. Converting the most important pages keeps them readable long after the app is gone.

Receipts and invoices. Web-based receipts are easy to lose. Saving them as PDF puts them alongside your other financial records.

Writing in Markdown? Skip HTML entirely

If your content starts life in Markdown, as README files, documentation and many notes do, there is a more direct route. Markdown to PDF turns the Markdown straight into a formatted PDF without you having to produce HTML first. It is also a good reminder that the simplest source often produces the cleanest PDF.

After converting: tidy, combine and protect

Converted HTML often needs a little finishing:

  • Too many pages? Long pages with navigation left in can produce blank or near-empty pages. Remove them with Remove Pages, or pull out just the section you need with Split PDF.
  • Several pages to send as one? Convert each file and combine them with Merge PDF. Our guide to organising PDF pages covers merging, splitting and reordering in detail.
  • Need page numbers for a long document? Add them with Add Page Numbers once everything is combined.
  • Contains private data? Encrypt it with Protect PDF before sharing.

Troubleshooting

Images are missing. They were probably loaded from another server. Save the page as "complete" so images are stored next to the HTML, or embed them in the file.

The layout looks broken or everything is stacked. The page relies on CSS layout features that document converters do not fully support. Simplify to a single column, or use a screenshot if you need the exact look.

Some content is missing entirely. It was added by JavaScript after the page loaded. Open the page in a browser, let it finish loading, then save it; the saved file will contain more of the rendered content.

Text is tiny or cut off at the edge. A fixed page width wider than the paper is being squeezed. Remove fixed widths or set a max-width.

Links are not clickable. Link text is kept, but whether links stay clickable depends on how they were written. Full web addresses (starting with https://) are the most reliable.

Frequently asked questions

Can I paste a website address instead of uploading a file?

Not in this tool. Save the page from your browser as an .html file and upload that.

Does the converter run JavaScript?

No. It converts the HTML as it is in the file, so content added by scripts will not appear unless it was saved into the file.

Will the PDF look exactly like the page in my browser?

Content and structure are kept, but complex CSS layouts can look different. Simple, document-style pages convert most faithfully.

Is the text in the PDF searchable?

Yes. Headings and paragraphs become real text, unlike a screenshot.

Are my files kept?

No. The file is deleted from the server as soon as the PDF is returned.

HTML to PDF works best when you treat the HTML as a document rather than an app: one column, local images, real tables and no clutter. Prepare the file with that in mind, convert it with HTML to PDF, and you will get a PDF that reads as cleanly on paper as it did on screen.

Was this article helpful?

Found this guide useful?

Share it with someone who is struggling with the same problem.

Free tool · No sign-up

HTML to PDF Converter

Convert an HTML file into a PDF document. Upload a .html or .htm file and download a printable, shareable PDF of the page.

Open tool
Toolyconvert Team profile photo

Written by

Toolyconvert Team

Web Development & Software Engineering Team

The Toolyconvert Team builds, maintains, and improves free online tools designed to make everyday digital tasks faster and easier. Our team works across web development, software engineering, APIs, performance optimization, testing, and user experience to create reliable and practical tools.