Skip to the content

Contact usFree tools · No signup · Files stay on your device

PDF Tools

HTML to PDF: the complete guide to saving HTML as a PDF document

HTML to PDF: the complete guide to saving HTML as a PDF document

HTML is the code behind web pages, emails and saved reports, and sometimes you just need it as a PDF: an invoice a shop system exported, a newsletter, a page of notes or a template you wrote by hand. The free HTML to PDF tool takes pasted HTML or a .html file and produces a clean, paginated PDF in your browser. It makes a tidy document version of the content, not a screenshot of the web page.

This guide covers each setting, exactly which parts of your HTML are read, how tables, links and pictures are treated, and what to do when the result is not what you expected. If you want to go the other way, see the PDF to HTML guide.

What HTML to PDF does

The tool parses your HTML with the browser's own parser, walks through the content, and draws it onto PDF pages. It keeps the things a document needs:

  • Headings, paragraphs and line breaks.
  • Bold, italic, underline and strike-through.
  • Text colours given in the HTML.
  • Bulleted and numbered lists, including nested ones.
  • Tables, block quotes, code blocks and horizontal rules.
  • Links that start with http://, https:// or mailto:, which stay clickable.
  • PNG and JPG pictures embedded in the HTML.

It does not reproduce CSS layouts such as columns, grids and floats, web fonts, background colours or images, and pictures that load from the web. It also does not fetch a page from a web address.

How to use HTML to PDF, step by step

  1. Open HTML to PDF.
  2. Paste your HTML into the box labelled "HTML to convert". You can also press Open file and choose a .html, .htm or .xhtml file, or press Try an example to see how it works.
  3. Under PDF options, choose the Page size, Margins, Font, Text size and whether to tick Page numbers at the bottom (Page 1 of 3).
  4. Press Convert to PDF & download. The PDF is saved at once and shown with its page count and a preview.
  5. If the page shows notes, such as "2 pictures from the web were left out", read them. They list what could not be kept.

A file you opened is named after it, with the .html ending replaced by .pdf. Pasted HTML is saved as html.pdf. Like every download from this site, the saved name starts with "Tech Solution Point - ". Use Clear to empty the box and start over. If you change any option after converting, the old result disappears and you press Convert again.

There is no drop zone on this page and no file-size limit. The only way to load a file is the Open file button. The file is read in the encoding its <meta charset> names (or its byte-order mark), and as UTF-8 when it names none.

Every option explained

Page size

A4, US Letter or US Legal. Use A4 for Bangladesh and most of the world.

Margins

Narrow (1.27 cm), Normal (2 cm) or Wide (2.54 cm). Narrow fits more on a page. Wide suits documents you will print and punch.

Font

Sans-serif (like Arial) or Serif (like Times). Inline code and <pre> blocks always use a typewriter font, whichever you choose.

Text size

Small (9 pt), 10 pt, Normal (11 pt), 12 pt or Large (14 pt). This is the size of body text. Headings scale from it: <h1> is about 1.64 times the body size, <h2> 1.36 times and <h3> 1.18 times. <h4> to <h6> all print at 1.09 times.

Page numbers at the bottom (Page 1 of 3)

Adds a small grey "Page 1 of 3" at the bottom centre of every page.

Which CSS is read

style="…" attributes written on an element are read, and simple <style> rules (see below), but only a few properties:

Property What it does in the PDF
color Sets the text colour. Near-white colours are ignored, because the page background is not reproduced.
font-weight Bold from bold or a number of 600 and above.
font-style Italic.
text-decoration Underline and strike-through.
font-family Typewriter font if the value mentions mono, courier or consolas.
text-align Left, centre, right or justified paragraphs.
display:none, visibility:hidden The element is left out. The hidden attribute does the same.
width, height on a picture Sets the picture size, in pixels.

The same properties are also read from a <style> block, for rules whose selector is a tag, a class, an id or a mix of them (p, .warning, p.warning, #total); an inline style="" wins over them. Everything else is ignored: linked stylesheets, rules such as div p or a:hover, and anything inside @media. If a colour or alignment matters, put it on the element or in a simple rule. Scripts, iframes, form controls, audio, video and canvas elements are never shown.

Tables. Each cell is flattened to a line of plain text, and cells that span columns with colspan leave empty cells next to them. The PDF table has thin borders around every cell. A first row of heading cells (<th>, or a row in <thead>) is bold and repeats on every page the table runs onto; there is no shading, and bold or links inside other cells are lost. A table too wide for the page is split into column groups, each headed like "Table · columns 5–8"; Landscape orientation fits more columns on a page. Row spans are not handled. For a spreadsheet-like table, Excel to PDF gives more control over the layout.

Links. A link whose address starts with http://, https:// or mailto: is blue, underlined and clickable. An in-page link such as href="#prices" jumps to the element with that id (its look is left as it is). A relative link to another file keeps its text but has no destination.

Pictures. Only a PNG or JPG written into the HTML as a base64 data: address is placed in the PDF, scaled down to fit the page width. If the <img> has a width or height, the other side follows the picture's shape. A picture loaded from a web address or a file path cannot be fetched, so its alt text is used if it has any, and a note counts how many were left out. GIF, WebP and SVG pictures are skipped with a note, and so are inline <svg> drawings.

Lists. Bullets use •, – and • at the first three levels. Numbered lists honour start, type (1, a, A, i, I) and an item's value.

Text spacing. Runs of spaces and line breaks in the source are collapsed, as in a browser, except inside <pre>, where every space and line is kept.

What it accepts and its limits

  • Input: pasted HTML or a file ending in .html, .htm or .xhtml. A complete page, or just a fragment such as a table or a few paragraphs, both work.
  • Scripts: never run. The HTML is only read.
  • Size: no limit is set by the page. Your device's memory is the limit.
  • Title: the page's <title> becomes the PDF's document title, which viewers show in the tab or title bar. It is not printed on the page. Without one, the file name is used.
  • Other scripts: Bangla, Arabic, Chinese, emoji and symbols such as the Taka sign ৳ are not in the standard PDF fonts, so the browser draws them and the PDF holds them as small pictures. A line that mixes Bangla and English becomes one picture, while a ৳ sign in an English line is drawn as a picture on its own and the rest of the line stays text. That drawn text looks right but cannot be selected or searched, and a note says so. If every character must be selectable, write amounts as "Tk 1,250" or "BDT 1,250".

Privacy

HTML to PDF runs entirely in your browser. The code is read with your browser's HTML parser and drawn into a PDF on your device. It is not uploaded, which matters for invoices and customer details. Pictures embedded in the HTML are used from the code itself, and nothing is downloaded from the addresses inside your HTML.

A worked example

Here is a small invoice, as it might come out of a shop system:

<h1>Invoice 1042</h1>
<p>Billed to <b>Rahim Traders</b>, Mirpur, Dhaka<br>Phone: 01712345678</p>
<table>
  <tr><th>Item</th><th>Qty</th><th>Price (Tk)</th></tr>
  <tr><td>Rice 50 kg</td><td>2</td><td>5,600</td></tr>
  <tr><td>Oil 5 litre</td><td>4</td><td>3,900</td></tr>
</table>
<p style="color:#c0392b;text-align:right">Payment due in 7 days</p>
<p class="note">Thank you for your order.</p>

Paste it, leave A4, Normal margins, Sans-serif and Normal (11 pt), and press Convert to PDF & download. The PDF has a large bold heading, the billing line with "Rahim Traders" in bold and a line break before the phone number, a three-column bordered table with a bold header row, a right-aligned red line, and the last paragraph as plain text. The note class has no effect here, because no <style> rule names it. Written as ৳ instead of "Tk", only the ৳ sign itself would be drawn as a small picture; the rest of the line stays selectable text.

Tips for a better PDF

  • Put the style you need on the element itself, for example style="text-align:center".
  • Embed small logos as base64 PNG or JPG. An <img src="logo.png"> cannot be loaded.
  • Remove navigation, cookie banners and footers from the source before converting a saved web page.
  • For a pixel-exact copy of a page as it appears on screen, use your browser's Print command and choose Save as PDF instead.
  • Page-break rules in CSS are not read. To control pages, split your content into separate conversions and join them with Merge PDF.
  • If the PDF is large, run it through Compress PDF.

Common problems and how to fix them

"There is nothing to put in the PDF. Check the html."

The HTML has no visible content: it may be only a <head>, only scripts, or only hidden elements. Paste the part that contains the body text.

The PDF looks plain compared with my page

That is expected. Layout, fonts and backgrounds are not reproduced, and only inline styles and simple <style> rules are read. Move the important styles inline, or use the browser's Print route.

A note says pictures were left out

Those pictures load from the web or from files. Convert them to base64 PNG or JPG data addresses, or accept the alt text.

Table headings are not bold

Only the first row is printed as a header, and only when it is made of <th> cells or sits in <thead>. Put the column names in such a row. Other cells are plain text, and there is no setting to change that.

Some characters show as boxes or odd symbols when I open the file

The file is read in the encoding named by its <meta charset> tag, or as UTF-8 when there is none. If an older file (for example Windows-1252) has no such tag, add <meta charset="windows-1252"> near the top, or save it as UTF-8 in a text editor.

Bangla text cannot be searched in the PDF

It is drawn as pictures, as described above. Use PDF OCR on the result if you need a searchable copy.

Quick checklist

  • Paste or open the HTML, then check the notes after converting.
  • Put colours and alignment inline or in simple <style> rules (tag, class or id).
  • Embed pictures as base64 PNG or JPG.
  • A ৳ sign is drawn as a small picture; write "Tk" if every character must be selectable.
  • Use Print and Save as PDF when you need the exact look of a page.

Frequently asked questions

Why is the styling from my CSS file or style block missing?
The tool reads style attributes on elements, such as style="color:red", and simple rules in a <style> block that name a tag, a class or an id (p, .note, p.note, #total). Linked stylesheets, rules with combinators such as div p, pseudo-classes and @media blocks are ignored, so the PDF is a clean document version of the page, not a copy of its design.
Why are my table headings not bold?
They are bold when they form the first row: a row of <th> cells, or the row inside <thead>, is printed bold and repeated at the top of every page the table runs onto. Other cells are plain text, so bold inside an ordinary cell, or a <th> further down the table, is not kept.
Can I paste a web address instead of HTML?
No. A browser page cannot read other websites, and the tool does not fetch pages for you. Save the page as a .html file or copy its source, then paste or open it here. For an exact copy of a live page, use your browser's Print and choose Save as PDF.
Which pictures appear in the PDF?
Only PNG and JPG pictures embedded in the HTML as data: URLs. Pictures that load from a web address or file path are left out, and the tool shows a note with how many were skipped.
Is my HTML sent anywhere?
No. The code is read with your browser's own HTML parser and the PDF is made on your device. Scripts in the HTML are never run.
Found this useful? Share it

Tools in this guide

Main tool

HTML to PDF

Turn HTML code or a saved web page into a clean PDF without installing anything.

Open tool

Text to PDF

Paste text or open a .txt file and get a clean PDF in seconds.

Open tool

PDF to HTML

Turn the text of a PDF into clean, semantic HTML.

Open tool

HTML to Word

Turn HTML code or a saved web page into an editable Word document without installing anything.

Open tool

Back to all guides & blog