HTML to PDF Converter
Operator: Abdulla Al Fahad. How tools are built and checked
This converter does not photograph a web page. It reads the HTML markup, works out what each element means (a heading, a paragraph, a list item, a table cell) and sets that content afresh on a Letter or A4 page with a fixed set of fonts and a footer. A browser's Print to PDF runs the full rendering engine, applies every stylesheet, loads the images and slices the painted page into sheets; this tool asks only structural questions of each element and draws the answers with one typographic scheme. It suits the text of a page as a clean, searchable PDF without navigation, adverts and sidebars, not a pixel-accurate record of how the page looked.
The trade is deliberate. A screenshot-style PDF is only as good as the page's print stylesheet and often arrives as images of text that cannot be searched; a re-layout gives selectable text, a small file, consistent margins and page numbers, and no dependence on remote images or fonts. Drop a saved .html file or paste markup copied from the page source or out of the developer tools, then press Convert text; Try a sample fills the box with a brief quarterly update that exercises a heading, a link, a nested list and a table.
Key features
- Reads real-world markup with the browser's own parser, as the HTML to Word converter does, then paginates it.
- Draws inline style attributes in the PDF: colour, highlight, font size, bold, italic, underline, strikethrough and alignment.
- Keeps table grids aligned across colspan and rowspan, shades and repeats header rows, and sets <code> and <pre> in Courier with indentation intact.
- Drops navigation, scripts, hidden elements, media and form controls, and reports skipped images and replaced characters.
- Writes the page's <title> into the PDF as its document title, names a pasted conversion after it, and adds a Page N of M footer to every page.
What survives from the markup
The markup is read by the browser's own parser with the rules the HTML to Word page sets out: heading tags become headings (h3 to h6 all third level), lists keep their nesting, tables keep their header row and spans, and scripts, styles, navigation, hidden elements, media and form controls are removed. What this page covers is how those blocks are drawn.
Inline style attributes are not just read, they are drawn: sizes, colours, highlights, weight, italics, underline, strikethrough and alignment set on an element reach the PDF, as the section below details, while rules in <style> blocks or linked stylesheets never do. Any font-family other than a Courier face is drawn as Helvetica, because those are the only fonts available, so a page whose headings are plain <div> elements styled by a class produces 11pt paragraphs.
Tables are drawn with equal column widths whatever their content, a thin grey grid and a shaded header row that is drawn again at the top of each page the table runs onto; a <caption> is set above it in italics. <pre> keeps its line breaks and indentation in Courier. Check boxes survive the parser as ☐ or ☑, which the PDF fonts cannot draw, so they turn into question marks and are listed in the warning. Links are drawn in blue with an underline but carry no clickable annotation. The <title> becomes the PDF's title metadata; the download is named after the uploaded file, or, for pasted markup, after the <title> or the first heading.
How it works
The browser's parser turns the markup into a DOM tree, which is walked once from <body> into headings, paragraphs, list items and table cells with bold, italic, colour, size and link attributes on their text runs, exactly as for the HTML to Word tool.
From there the Word to PDF converter's page writer takes over, and its page explains the metrics: text is checked against the Helvetica character set, wrapped to the content width, placed down each page and finished with the footer. The one HTML-specific twist is that run-level sizes and colours from style attributes survive into the drawing pass, so a 24px span becomes an 18pt run on a taller line.
Common use cases
- A support team turns a knowledge-base article exported as HTML into a PDF that can be attached to a ticket reply.
- A developer converts the HTML report emitted by a test runner or a monitoring job into a PDF for a weekly status email.
- A lawyer saves the terms-and-conditions page of a website as a dated, searchable PDF without its menus and cookie banners.
- A researcher archives a long-form article from a site that will not print cleanly because of fixed headers and infinite scroll.
How to use this tool
- Upload a saved page (.html, .htm or .xhtml), or paste its markup and press Convert text.
- Leave Page size on US Letter or switch it to A4; the PDF page chip updates at once.
- Note any warning about images or replaced characters, then look at the start and end of the preview for header and footer leftovers you want to cut.
- Download the .pdf, or send the document to the Word editor with Edit in Word editor if boilerplate needs cutting first.
Example
HTML input
<title>Service status - May</title>
<nav><a href="/">Home</a> · <a href="/status">Status</a></nav>
<h1 style="color: #c00">Service status</h1>
<p>Uptime was <strong>99.95%</strong>; see the
<a href="https://example.com/report">full report</a>.</p>
<p class="note">Two incidents, both
<span style="font-size: 24px">resolved</span>.</p>
<ul><li>Database failover
<ul><li>Lasted 12 minutes</li></ul></li></ul>
<img src="chart.png" alt="Uptime chart">Service status - May.pdf (pasted markup is named from <title>)
(nav dropped)
Service status Helvetica-Bold 20pt, colour CC0000
Uptime was 99.95%; see the full report.
"99.95%" bold; "full report" blue + underline, not clickable
Two incidents, both resolved. "resolved" 18pt (24px × 0.75)
class="note" ignored: no stylesheet is read
• Database failover bullet 0.25in in, text 0.5in in
• Lasted 12 minutes nested one level deeper
(img counted, not drawn)
Page 1 of 1 9pt grey, centred
Warning: 1 image was left out.Tips for best results
- Copy the article's own element out of the browser's Elements panel rather than using View Source. Pages rendered by JavaScript have an empty source, and the rendered DOM lets you leave the menus and footer behind.
- Put a <title> in pasted markup. It becomes the PDF's document title and names the download; without one the first heading is used, and failing that the file is called Converted document.pdf.
- If a page's headings are plain <div> elements, wrap them in <h2> before converting, or add style="font-size: 15pt; font-weight: bold" to have them drawn at that size and weight.
- Every table column gets the same width, so remove empty or redundant columns before converting a table with one long text column.
- <footer> content is kept, so if a converted page ends with copyright lines and link lists, cut the element from the markup or delete those paragraphs in the Word editor.
Edge cases to watch
A page built on layout tables comes out as a grid: the converter cannot tell a sidebar-and-article table from a data table, so the sidebar text lands in a cell beside the article.
Floats, columns and grid layouts are flattened into source order, so a two-column CSS layout is read top to bottom through the markup.
Images, SVG charts, canvases and videos vanish; only the images are counted in the warning.
Links do not work in the PDF: the text is blue and underlined, but there is no link annotation and the href is not printed.
Common errors and how to fix them
- Paste some HTML first.
- The box was empty when you chose Convert text. Paste markup, or load the sample, and convert again.
- No text was found in the pasted HTML.
- Everything you pasted sits inside dropped elements such as <nav>, <script> or hidden containers, or the <body> is filled in by JavaScript and empty in the source. Copy the rendered markup out of the developer tools instead.
- This converter accepts HTML files (.html, .htm), up to 25MB. "saved-page.mhtml" has a different extension.
- A .mhtml or .webarchive file is a single-file web archive, not HTML, and the file picker turns it away. Save the page again with the browser's HTML only or Web page, complete option and upload the .html file; the folder of images saved beside it is not needed.
Best practices
- Trim the markup to the content before converting: one <article> or <main> element pasted from the developer tools gives a far cleaner PDF than a whole page.
- Read the warning line before cutting images from the markup: the count tells you how many figures the PDF will lack.
- Make sure a table's first row uses <th> cells or sits inside <thead>. Otherwise it is drawn as an ordinary row, with no shading, and is not drawn again when the table runs onto another page.
What a style attribute becomes on the page
The converter reads a fixed list of properties from each element's style attribute. font-size is converted to points: pixels at 0.75pt per pixel, em and rem relative to 11pt, points as written, so font-size: 24px is drawn at 18pt and font-size: 1.5em at 16.5pt, each on a line tall enough for it. color and background-color accept #hex (three or six digits), rgb() and rgba() and about thirty named colours; the colour becomes the text colour and the background a highlight rectangle behind the words, except white, which is ignored. font-weight: bold or a number of 600 and above gives bold, font-style: italic gives italic, text-decoration gives underline or strikethrough, and text-align: center, right or justify sets the paragraph's alignment.
font-family is honoured only as far as the PDF can honour it: a Courier face selects the monospace font and everything else is Helvetica, so a page set in Georgia and a page set in Arial produce the same PDF. Because only the attribute on the element itself is read, a class that makes a note red has no effect while style="color: #c00" on the same element does. When a page relies on its stylesheet for something that matters in the PDF, paste the markup into a text editor and move those few declarations inline before converting.
Frequently asked questions
Can I give it a URL instead of a file?
No. Browsers block a page from fetching another site's markup, and the converter deliberately has no server to do it instead. Save the page as HTML, or copy the element you want from the developer tools, then upload or paste it.
Does the PDF include the page's <title>?
Yes, as the document title shown in a reader's title bar. The download itself is named after the uploaded file; only a pasted conversion takes the <title> as its file name.
Why is my page's content in the wrong order?
The markup is read in source order, so a sidebar placed first in the HTML but shown on the right by CSS comes out first. Paste only the main content element to avoid it.
What happens to form fields and buttons?
They are removed, along with their labels' meaning. Only check boxes leave a trace, as a box symbol that the PDF fonts cannot draw and therefore show as a question mark.