Skip to content
AgileLogics

HTML to PDF

Extracts the visible text from pasted HTML and lays it out as a downloadable PDF. Text only — layout, styling, and images are not preserved.

Working on a whole file? Open it in the HTML editor →

How it works

Paste HTML and click Convert.

What does this HTML to PDF converter keep, and what does it drop?

This converter keeps the visible text of your HTML and drops everything else. It parses the markup, walks the body, starts a new line for every block element such as a heading, paragraph, list item or table row, and writes the result into a plain US Letter PDF in 12-point Helvetica. Styling, images and links don't survive. The output downloads as document.pdf.

That's a deliberate scope. Rendering HTML and CSS faithfully needs a full browser engine, and your browser already has one (more on that below). This tool is for the narrower job of getting the words out of a lump of markup and into a readable PDF quickly, without uploading anything.

A worked example

Paste this and click Convert:

<h1>Quarterly update</h1>
<p>Revenue rose 4% &amp; costs fell.</p>
<ul><li>Hiring paused</li><li>New office in Leeds</li></ul>

The PDF contains four lines:

Quarterly update
Revenue rose 4% & costs fell.
Hiring paused
New office in Leeds

The &amp; entity became a real ampersand, and each block element got its own line, even the two list items that had no whitespace between their tags. Inline elements such as strong, a or span stay within the line they belong to.

How the text is collected

  1. Everything in head is ignored, as are script, style, noscript, template, iframe, svg, canvas and select elements in the body.
  2. Elements with the hidden attribute or an inline display:none or visibility:hidden style are skipped. Elements hidden by a stylesheet class are still included, because no CSS is applied.
  3. Block elements (p, div, h1 to h6, li, tr, blockquote, section and similar) become separate paragraphs, with a small gap between them.
  4. A br starts a new line, and two in a row leave a blank line.
  5. Table cells in a row are joined with a space, so <td>Pens</td><td>4</td> prints as "Pens 4".
  6. Inside pre, line breaks are kept, but runs of spaces are still collapsed, so indentation is lost.

Page layout

Property Value
Page size US Letter, 612 x 792 points (8.5 x 11 in)
Margins 50 points (about 0.7 in) on every side
Font Helvetica, 12 pt, black
Line spacing 16.8 pt (1.4 x the font size), plus 7.2 pt between paragraphs
Lines per page Up to 42, then a new page starts
Long words Split across lines when wider than the text area

Lines wrap at spaces. A single unbroken string wider than the 512-point text area, like a long URL or a base64 blob, is broken mid-word onto the next line rather than running off the page, so nothing is cut off.

Characters that can't be drawn

The tool uses Helvetica as one of PDF's built-in standard fonts with WinAnsi (Windows-1252) encoding (ISO 32000-1, Annex D). That covers English and most Western European accented letters, plus symbols such as €, £, curly quotes and dashes. Anything else stops the conversion with a message naming the character:

Input contains Result
café, naïve, €20 Works
Rupee sign ₹ "The character "₹" (U+20B9) can't be drawn with this tool's built-in PDF font..."
Cyrillic, Greek, Arabic, CJK, emoji The same message, naming the first such character
Only tags, no text (<img src="a.png">) "No visible text found in that HTML."
Empty box Nothing happens

Invisible zero-width characters (zero-width space, joiners and the byte-order mark) are removed before the check, since they draw nothing anyway.

When you need the real layout

Use the browser's own print engine. Open the HTML in a browser tab, press Ctrl+P (Cmd+P on a Mac), and pick "Save as PDF" as the destination. That honours your CSS, including print-specific rules such as the @page at-rule for paper size and margins, and it can embed fonts for any script. If you have a snippet rather than a file, render it in the HTML viewer or tidy it in the online HTML editor first, then save it as an .html file and open that.

Related tools

  • Word counter: check how much text you're about to put in the PDF.
  • HTML encoder and decoder: turn entities like &amp; into characters, or back, without making a PDF.
  • Learn HTML: a refresher on which elements are block-level, which decides where this converter starts new lines.

Last updated

Frequently asked questions

Does this preserve my page's design?
No. Only the visible text is kept, laid out in 12-point Helvetica with each heading, paragraph, list item or table row on its own line. Colours, fonts, sizes, links and images are not preserved. For a faithful copy, open the page in a browser and use Print, then Save as PDF.
Will CSS or JavaScript code end up in my PDF?
No. The contents of style, script, noscript and template elements are skipped, along with anything in the head. Elements hidden with the hidden attribute or an inline display:none or visibility:hidden style are skipped too.
Why does it say a character can't be drawn?
The PDF uses the built-in Helvetica font, which only covers Western European characters. Text with other scripts or symbols, such as the rupee sign, Cyrillic, Chinese or emoji, can't be converted, so the tool stops and names the first such character, for example "₹" (U+20B9), so you can replace it.
Can I convert a web page by entering its URL?
No. The tool only reads HTML that you paste into the box and doesn't fetch pages. Stylesheets and images referenced in the markup play no part in the output either. Copy the page source yourself if you want its text.
Is the HTML sent to a server?
No. The HTML is parsed by your browser's built-in DOMParser and the PDF is written by pdf-lib on your device.