Skip to content

HTML to PDF

✨ Preview updates as you type 0 lines · 0 B

PDF

Paste HTML on the left

You’ll see it here on paper, page by page
Nothing to convert yet

HTML to PDF Converter – Save HTML as PDF Online

What is an HTML to PDF Converter?

It takes a web page (or any piece of HTML) and turns it into a PDF file with real pages: A4 or Letter, with margins, page breaks and everything. You paste the code, see exactly how it lands on paper, and download the PDF. It’s handy for invoices and receipts you built as HTML, reports, CVs, email templates you want to send as an attachment, or documentation pages you need to hand to someone who doesn’t live in a browser.

This converter runs in your browser. Your HTML isn’t uploaded anywhere, and it gives you two ways to get the PDF: Download PDF makes the file in one click, and Print / Save as PDF uses your browser’s print window for sharp text you can select. More on which one to pick below.

How to Convert HTML to PDF – Step by Step

Five short steps. Click Sample in the tool above to follow along with an invoice.

Step 1 Paste or Open Your HTML

Get your HTML into the left panel, whichever way is easiest:

  • Paste it: a snippet, a full page, or the source of a site (Ctrl+U shows it in most browsers).
  • Open an HTML file: click the upload button, or drag the .html file onto the tool. That’s the quickest way to turn an HTML file into a PDF.
  • Click Sample: loads a small invoice with a colored header, a table and a second page.

The paper preview on the right updates as you type.

Step 2 Pick the Paper, Orientation and Margins

A4 (210 × 297 mm) is the standard almost everywhere. Letter (8.5 × 11 inches) is what the US and Canada use. Legal, A3 and A5 are there too. Portrait is tall, Landscape is wide and suits big tables. Margins go from none to 20 mm on every side.

Your page is laid out at the width of the paper minus the margins, just like a printer would. On A4 with 10 mm margins that’s about 718 pixels wide, so a layout built for a big screen switches to its narrower version (its media queries see the paper width).

Step 3 Check the Page Breaks in the Preview

The preview shows your page on a white sheet. A dashed line marks where one page ends and the next begins, and the status bar counts the pages. Want something to start on a fresh page? Give it break-before: page in your CSS:

Try it: a report with a second page

HTML:

<h1>Annual report</h1>
<p>A short summary…</p>

<!-- This starts on page 2 -->
<section class="chapter">
  <h2>Sales</h2>
  …
</section>

CSS:

/* Every chapter starts on a new page */
.chapter { break-before: page; }

/* Keep these in one piece */
tr, figure, .card { break-inside: avoid; }

Download PDF also moves paragraphs, list items, table rows, images and headings to the next page when they’d be cut in half (as long as they fit on one page).

Step 4 Backgrounds and JavaScript

  • Backgrounds (on by default) keeps background colors and images. Browsers drop them when printing to save ink. Turn it off for a plain, printer-friendly copy, but watch for white text on a dark background: it disappears without the background.
  • JavaScript (off by default) lets your page’s own scripts run first, for pages that build their content with JavaScript. Scripts run in a locked-down frame that can’t reach this site or your data.
  • File sets the PDF’s name. Leave it empty to use the page’s <title>.

Step 5 Download PDF or Print / Save as PDF

  • Download PDF (the lime button) makes the .pdf file and saves it. Usually it takes a second or two.
  • Print / Save as PDF opens your browser’s print window with the same paper and margins. Set the printer (Destination) to Save as PDF and click Save.

Download PDF or Print to PDF: Which One?

Both give you a PDF. They’re made in different ways, so each is better at something:

Download PDFPrint / Save as PDF
How it’s madeEach page is drawn as a picture and put in a PDFYour browser prints the page to a PDF
Select, copy and search textNoYes
Clickable linksYesYes
Matches the previewYes, page breaks includedClose, but the browser places page breaks itself
Images from other websitesOnly when the site allows itYes
Your @media print CSSNot usedUsed
LengthUp to 200 pagesNo limit
ClicksOneA few (pick “Save as PDF”, then Save)

A simple rule: use Download PDF for a quick copy that looks exactly like the preview, and Print / Save as PDF for anything people will read closely, search or copy from, like a CV.

Tips for a Good-Looking PDF

Control the page breaks

break-before: page starts a new page and break-inside: avoid keeps a table row, card or figure in one piece. The older page-break-before: always works too.

Let the tool set paper and margins

The Paper and Margins settings win over any @page rule in your CSS, so you can switch from A4 to Letter without touching the code.

Use full image addresses

Relative paths like images/logo.png can’t load here, because the tool only has your HTML. Use a full https:// address or put the picture in the HTML as a data: URL.

Fonts

System fonts always work. Web fonts from Google Fonts work in both ways of saving. If text shows as empty boxes, your computer has no font for that language, so add one.

Print-only styles

Rules inside @media print (like hiding the menu) only apply in Print / Save as PDF. The preview and Download PDF show your screen styles.

Keep text dark

If you turn Backgrounds off, give text on colored bands a dark color, or it may vanish on white paper.

Example: hide the menu when printing, and images that work

CSS:

/* Only used by Print / Save as PDF */
@media print {
  nav, .no-print { display: none; }
  a { color: inherit; }
}

Images:

<!-- Works: a full address on a site that allows it -->
<img src="https://images.example.com/team.jpg" alt="Our team">

<!-- Works anywhere: the picture is inside the HTML -->
<img src="data:image/png;base64,iVBORw0KGgo…" alt="Logo">

<!-- Doesn't work here: the tool doesn't have this file -->
<img src="images/logo.png" alt="Logo">

What It Can’t Do

Frequently Asked Questions

How do I convert HTML to PDF?

Paste your HTML into the box on the left, or open an .html file. Pick the paper size, orientation and margins, check the paper preview on the right, then click Download PDF. If you’d rather have text you can select, click Print / Save as PDF and choose “Save as PDF” as the printer.

What’s the difference between Download PDF and Print / Save as PDF?

Download PDF makes the file for you in one click, and it looks exactly like the preview. Each page in it is a picture of your page, so links still work but you can’t select or search the text. Print / Save as PDF opens your browser’s print window. The browser lays out the pages itself, so page breaks can land a little differently, but the text stays sharp at any zoom and you can select and copy it. For a CV, an invoice you’ll email or anything people will search, Print / Save as PDF is usually the better pick.

Why can’t I select the text in the downloaded PDF?

Download PDF draws each page as a picture (sharper than your screen, so it stays readable) and puts the pictures in a PDF. That’s how it can match the preview so closely, but a picture has no text inside it. Use Print / Save as PDF when you need text you can select, copy or search.

Is my HTML uploaded anywhere?

No. The preview and the PDF are both made in your browser. The first time you click Download PDF, your browser loads the PDF-making code from our site, but your HTML never leaves your computer. The only other requests are the ones your HTML makes itself, like loading its images, fonts or stylesheets.

Can I convert a web page to PDF by its URL?

Not here. Browsers don’t let one website read the pages of another, so a tool running in your browser can’t fetch a page by its address. Open the page, press Ctrl+U (Cmd+Option+U on a Mac) to see its source, and paste that in. Or save the page as an .html file and open it with the upload button. For a page you’re looking at right now, your browser’s own print window can also save it as a PDF.

Why is an image missing from my PDF?

With Download PDF, an image from another website only makes it in when that site allows other sites to use it (this is called CORS). If it doesn’t, the tool leaves the space blank and tells you how many images it couldn’t add. Print / Save as PDF usually includes them. Relative paths like images/logo.png can’t work at all, because the tool only has the HTML you pasted, not the files next to it. Use a full https:// address or a data: URL instead.

How do I start a new page or stop a table row from being cut in half?

Add break-before: page to the element that should start a new page, for example h2 { break-before: page; }. To keep something in one piece, add break-inside: avoid, for example tr, figure { break-inside: avoid; }. Both work with Download PDF and with Print / Save as PDF. Download PDF also moves paragraphs, list items, table rows, images and headings to the next page by itself when they’d be cut and fit on one page.

Why are my background colors missing?

Make sure Backgrounds is ticked. Browsers leave background colors and images out when printing to save ink, and that box tells them to keep them. Without backgrounds, light text on a dark background (like a white heading on a dark band) can disappear, the same as when you print a web page with “Background graphics” turned off.

Does it run the JavaScript in my HTML?

Only if you tick JavaScript. It’s off by default, so scripts, onclick handlers and javascript: links are removed before anything is shown. Turn it on when your page builds its content with JavaScript, like a chart or a table filled in by a script. Either way your code runs in a locked-down frame that can’t reach this website, your cookies or anything else on your computer.

Does it work with Arabic, Hindi, Chinese or emoji?

Yes. Both ways of making the PDF use your browser’s own text drawing, so right-to-left text, joined letters and emoji come out the way you see them in the preview. If a language shows up as empty boxes, your computer doesn’t have a font for it. Add a web font (for example from Google Fonts) to the HTML and it’ll be used in the PDF too.