HTML to PDF Converter

Paste HTML and CSS or enter a page URL, choose page size, orientation and margins, and download a sharp vector PDF.

Extra CSS (optional)
Page size
Orientation

Live preview

The preview uses your browser's engine. The PDF engine supports most CSS 2.1 and some CSS3, but not flexbox or grid, so check the PDF before you send it.

Pasted HTML is sent to our server only to build the PDF and is not stored. Links, images and fonts load only over https.

In short

Paste your HTML (and optional CSS) or enter the address of a public web page, pick A4, Letter, Legal or 4 x 6 in, portrait or landscape, and a margin, then click Convert to PDF. Our server draws a vector PDF with selectable text in a few seconds. Scripts are removed and never run.

On this page
  1. How to convert HTML to PDF
  2. Convert a web page by its address
  3. Page sizes, orientation and margins
  4. What CSS works in the PDF
  5. Getting a design ready for print
  6. When to use Print with my browser instead
  7. Example: a wholesale order summary
  8. Common uses in a store
  9. Limits and privacy
  10. Troubleshooting

HTML is the easiest way to lay out a document with your own fonts, colors and tables, and PDF is the format people expect to download, print and attach to an email. This converter joins the two. Paste the markup for an order summary, a price list, a report or a one-page flyer, or point it at a public web page, and it returns a real PDF: text you can select and search, sharp lines at any zoom, and the page size you chose.

The PDF is drawn on our server with Dompdf, an open-source HTML and CSS layout engine written in PHP. It follows the CSS you give it, including print styles and @page rules, but it is not a web browser. The sections below explain what it supports, where it differs from Chrome, and when the browser print option on the same page is the better choice.

How to convert HTML to PDF

  1. Stay on the Paste HTML tab and paste your markup into the HTML box. A full page with <html>, <head> and <style> works, and so does a fragment such as a single table. Load the sample fills in a wholesale order summary you can edit, and Open an .html file reads a file from your computer.
  2. Optional: open Extra CSS and add rules. They are applied after the page's own styles, so they win on equal specificity.
  3. Watch the Live preview. It shows the page at the width of the printable area for the paper size and margins you picked.
  4. Choose a Page size (A4, Letter, Legal or 4 x 6 in), an Orientation and Margins from None (0 mm) to Wide (25 mm).
  5. Type a File name, or leave it empty to use the page's <title>.
  6. Click Convert to PDF. You get a preview of page 1, the page count and the file size, with Download PDF and Open in a new tab buttons.

Your HTML is saved in this browser as you type, so it is still there if you reload the page. It is not saved on our server.

Convert a web page by its address

Switch to the Web page address tab, paste a link such as https://example.com/pricing and click Convert to PDF. Our server downloads the page's HTML, then renders it with the page's own stylesheets and images, resolving relative links against the page address.

Three things decide how well this works:

  • JavaScript does not run. The converter reads the HTML the server sends. Pages that build their content in the browser, such as many web apps, some store themes and pages behind a cookie banner, come out empty or partial. For those, open the page in your browser, press Ctrl+P (Cmd+P on a Mac) and choose Save as PDF.
  • Print styles apply. The converter uses the print media type, the same as a browser's print dialog. If the site hides its menu or footer when printing, the PDF hides them too.
  • Only public pages. The address must be a public site on the normal web ports. Addresses on private networks and HTML pages over 2 MB are refused, and a page behind a login converts as its login screen.

Page sizes, orientation and margins

SizePortrait dimensionsTypical use
A4210 x 297 mmInvoices and documents outside North America
Letter8.5 x 11 in (215.9 x 279.4 mm)US and Canadian documents
Legal8.5 x 14 in (215.9 x 355.6 mm)Contracts and long forms
4 x 6 in101.6 x 152.4 mmShipping and packing labels for thermal printers

The size, orientation and margins you pick are written into the document as an @page rule placed after all of your CSS, so they take priority over any @page rule already in your HTML. With Normal margins (15 mm) on A4 portrait, the printable width is 180 mm, which is about 680 CSS pixels at 96 per inch. Design to that width and nothing will be cut off.

What CSS works in the PDF

Dompdf handles most of CSS 2.1 and some CSS3. In practice that covers the documents people usually make: text styling, colors, borders, backgrounds, rounded corners, tables, floats and positioned boxes. According to Dompdf's own documentation, it does not support flexbox or grid.

FeatureIn the PDFWhat to do instead
Tables, colspan, rowspan, bordersSupportedUse tables for columns side by side
Floats and position: absoluteSupported
page-break-before, page-break-afterSupportedAdd style="page-break-before: always" to start a new page
@media print and @pageSupportedPage size and margins come from the options above
Flexbox and CSS gridNot supported; items stackUse a table, or Print with my browser instead
Inline <svg> markupNot supportedUse <img src="https://.../logo.svg"> or a data: URI
PNG, JPEG, GIF, BMP imagesSupported over https or as data: URIsRelative paths need the URL mode or a full address
Web fonts@font-face with TTF files over httpsUnicode text falls back to DejaVu Sans, which covers most languages written in Latin, Greek and Cyrillic
JavaScriptNever runs; <script> tags are removedPaste the HTML after the script has built it

Tip: Dompdf cannot split a single table row across two pages. If you have a row with a very long cell, break the content into several rows so the table can flow onto the next page.

Getting a design ready for print

A layout that looks right in a browser window can still print badly, because a page has a fixed width and the screen does not. A few habits make the PDF match what you expect the first time.

  • Use print units. Sizes in pt, mm or in map directly to the page: 10pt body text and 1mm borders look the same on every printer. Pixels work too, at 96 per inch, so a 680px wide block fills an A4 page with 15 mm margins.
  • Use percentage widths. A table set to width: 100% fits Letter, A4 and landscape pages without changes. A fixed 900px layout gets cut off on a portrait page.
  • Keep images light. A 4000 pixel product photo shown at 2 inches wide makes the PDF large without looking better. Resize it first with the image resizer; around 300 pixels per printed inch is plenty.
  • Set colors on purpose. Very light gray text and thin hairlines can disappear on office printers. Use at least #6b7280 for secondary text and 1px or thicker borders.
  • Name a font that exists. If your CSS asks for a font the engine does not have and you did not load it with @font-face, the text falls back to DejaVu Sans. That keeps every character visible, but the look changes, so check the preview on the result card.
  • Control breaks. Put page-break-inside: avoid on small boxes such as an address block or a totals table, and a page break before each new section of a long report.

When to use Print with my browser instead

The Print with my browser instead button sends your pasted HTML to your own browser's print dialog through a hidden frame, with the same page size and margins, and with scripts disabled. Choose Save as PDF as the destination. Use it when:

  • your layout depends on flexbox or grid,
  • you need a font your browser has but that is not available as a TTF file online,
  • you have used today's free server conversions.

The browser's PDF is also vector and searchable. The differences are that the result depends on your browser version, you need to turn off the headers and footers option in the print dialog for a clean page, and background colors print because the converter asks the browser to keep exact colors.

Example: a wholesale order summary

The built-in sample is a one-page order summary with a heading, a shipping box and a four-column table: three product lines of 24 x $18.50 = $444.00, 48 x $6.25 = $300.00 and 36 x $7.40 = $266.40, and a bold total of $1,010.40. It uses only table layout, borders and background colors, so the PDF matches the preview. On A4 with Normal margins it converts to a single page of about 25 KB. Try switching to Letter and Landscape: the table gets wider, the page count stays at one, and nothing else in the HTML needs to change.

If you build documents like this from data, such as invoices from an order export, the JSON to PDF template generator fills the HTML for you from JSON and then uses the same PDF engine. For a ready-made store invoice, the Shopify invoice generator is quicker.

Common uses in a store

Most online sellers already have HTML they want as a PDF, even if they do not think of it that way:

  • Line sheets and price lists for wholesale buyers, built as a table of products with prices and minimum order quantities.
  • Order confirmations and packing slips copied from an email template, so a warehouse can print them.
  • Size charts and care guides from a product page, saved as a PDF to include in the box or attach to a marketplace listing.
  • Policy pages such as returns and shipping terms, for B2B customers who ask for a signed copy. Our refund policy generator writes the text; this tool turns it into a PDF.
  • Reports exported from a dashboard as HTML, turned into a file you can send to a partner who will not log in.

Limits and privacy

  • HTML up to 2 MB and extra CSS up to 500 KB. Embedded base64 images count toward the 2 MB, so link large images by https address instead.
  • Up to 8,000 HTML elements per document, which is roughly 60 pages of a large table. Bigger documents are refused with a message rather than timing out.
  • Linked images, stylesheets and fonts load only over https, only from public addresses, with a 6 second timeout each, no redirects, and at most 40 files per document. Files that are skipped are counted on the result card.
  • There is a daily limit of free conversions per visitor. When you reach it, the tool tells you, and browser printing still works.
  • Your HTML is sent to our server only to build the PDF. It is not saved, logged or shared, and the PDF is returned straight to your browser.

Once you have the PDF, you can join it with other files in Merge PDF or shrink it with Compress PDF, both of which run in your browser.

Troubleshooting

ProblemCauseFix
Columns stack on top of each otherFlexbox or grid layoutRebuild the columns as a table, or use browser print
Images are missingRelative path, http address, or a private hostUse a full https address or a data: URI
Text shows as boxesThe font lacks those charactersSet font-family: DejaVu Sans or load a TTF that has them
A web page converts emptyIts content is drawn by JavaScriptPrint it from your browser instead
Content is cut off at the rightFixed widths wider than the printable areaUse percentage widths or Narrow margins
A table row jumps to the next pageRows cannot split across pagesSplit long cells into several rows

Frequently asked questions

Is the HTML to PDF converter free?

Yes. Conversions are free with a daily limit per visitor, with no sign-up and no watermark. When you reach the limit, Print with my browser instead still works without limits because it uses your own browser.

Does the converter run JavaScript?

No. Script tags are removed and inline event handlers are stripped before rendering, and the engine has no JavaScript interpreter. That keeps the server safe, but it means content built by scripts will be missing. Paste the finished HTML, or use your browser's print dialog for script-heavy pages.

Why does my flexbox layout look wrong in the PDF?

The PDF engine, Dompdf, supports most of CSS 2.1 and some CSS3 but not flexbox or grid, so flex items stack vertically. Use a table for side-by-side columns, which is how most invoice and report templates are built, or switch to Print with my browser instead.

Is the PDF text selectable and searchable?

Yes. The PDF is vector, not a screenshot. Text stays as text you can select, copy and search, lines stay sharp at any zoom, and links in your HTML stay clickable. File sizes are small: the one-page sample order summary is about 25 KB.

Can I convert any website to PDF?

Any public page that sends its content as HTML, up to 2 MB. Pages behind a login, on a private network, or drawn with JavaScript will not convert properly. For those, open the page and use your browser's print dialog with Save as PDF.

How do I add a page break?

Put style="page-break-before: always" on the element that should start a new page, or page-break-after: always on the one that should end a page. The engine honors both. A single table row cannot be split, so very tall rows move to the next page whole.

Do you keep a copy of my HTML or PDF?

No. The HTML is sent to our server only to build the PDF, and the PDF is sent straight back to your browser. Neither is stored or logged. The HTML you type is saved in your own browser so it survives a reload.