HTML to PDF

Generate PDF via browser.

Loading tool…

Turning a web page into a document

HTML describes content that reflows to fit any viewport. PDF describes fixed pages of a defined size. Converting one to the other means pagination: deciding where content breaks across page boundaries, how margins and headers are applied, and what happens to elements that do not fit.

CSS has a whole vocabulary for this. The @page rule sets page size and margins, page-break-inside: avoid keeps a table or figure from being split across pages, and print media queries let you hide navigation and buttons that make no sense on paper. Ignoring all of that is why naive conversions produce documents with headings stranded at the bottom of a page and tables cut in half.

Why we built this tool

The common jobs are generating an invoice or a report from a template, saving a formatted document for signing or archiving, and producing something printable from content that lives as HTML.

Invoices and reports contain customer names, addresses, amounts, and account details. Server-side conversion services receive all of it, and many free ones stamp a watermark on the output as payment. Ours renders the page in your browser and writes the PDF locally, so the document is generated on your machine, nothing is transmitted, and the output carries no branding but yours. There is also no page limit and no queue.

Tips and common mistakes

  • Add print CSS to hide navigation, buttons, and anything else meaningless on paper.
  • Use page-break-inside: avoid to stop tables and figures being split across pages.
  • Set explicit page size and margins rather than relying on defaults.
  • Check the last page — content that overflows by a line is the most common formatting fault.

Open HTML to PDF with a link

Assistants and scripts can open HTML to PDF with its input already in the link, after the #, which never leaves your device:

  • #text= — the text to work on
  • #html= — the HTML

Example: https://mygadgets.ink/tools/html-to-pdf/#text=...&html=... · also compressed gz fields and ?url=. How tool links work

Quick start: using HTML to PDF

  1. Paste your HTML into the input above, including any styles it depends on.
  2. Set the page size and orientation — A4 portrait for most documents.
  3. Generate the PDF and review the page breaks carefully.
  4. Adjust the markup or add print CSS rules if content is splitting badly.
  5. Download the finished document.

Write the source in Markdown and convert it first with Markdown to HTML, then shrink the result with Compress PDF.

Why convert HTML to PDF

HTML is fluid — it reflows to fit any screen. That flexibility is wrong when you need a document that must look exactly the same for everyone: a PDF has fixed pages, fixed layout, and prints the same from any device. Converting is how you turn a web-based invoice, certificate, or report into a professional, sendable file.

Why the PDF may not match the browser exactly

The most common surprise: the PDF looks slightly different from the page on screen. This happens because print rendering follows different rules than screen rendering. To get a faithful result:

  • Design for print. Screen layouts assume infinite scroll; a PDF has fixed page boundaries. Content gets split across pages.
  • Watch page breaks. A table or image can be cut awkwardly across two pages. CSS print rules (page-break) control where breaks fall.
  • Mind the width. Very wide layouts get shrunk or clipped to fit the page. Content sized for a standard page (like A4 or Letter) converts cleanly.
  • Backgrounds and colors may be dropped unless explicitly set to print, since print defaults favor ink saving.

Getting clean pages

  • Keep it simple. Straightforward, document-like HTML converts far more reliably than a complex interactive page.
  • Test one page first before converting a long document, so you catch layout issues early.
  • Use print-friendly styling — readable fonts, sensible margins, no fixed-position elements that overlap.

Common uses

  • Generate invoices and receipts from web templates.
  • Save a report as a fixed document.
  • Create certificates or formatted letters.
  • Archive a page in printable form.

Related Document Tools

Browse all Document Tools →