HTML to PDF turns a web page or a piece of HTML markup into a PDF you can download and share. Paste a fragment, upload an .html file, choose the paper size and quality, then check the preview. Everything is rendered and converted in your browser, so the document is never uploaded to Lembog.
How to convert HTML to PDF
- Choose Paste HTML and enter your markup, or Upload file and select an .html or .htm file up to 5 MB.
- Choose A4 or Letter, orientation, margin, capture scale and background colour.
- Check the approximate preview.
- Click Convert HTML to PDF; the progress bar tracks each encoded page.
- Download the result:
your-file-html.pdfafter an upload, otherwisehtml-to-pdf.pdf.
Paste HTML or upload a file
Paste mode suits short documents such as invoices, quotes, certificates or saved email layouts. Fragments and complete HTML documents both work: a readable base stylesheet is added, then your own CSS applies on top. Upload mode reads .html or .htm as UTF-8 text and shows the filename and size; the original is untouched. The 5 MB limit applies to the HTML, not the finished PDF, since data-URL images can make a small file produce a large PDF. Scripts are disabled in both modes, so content built only by JavaScript will not appear. Relative image paths have no connection to the folder you uploaded from, so use absolute or data URLs.
Choosing page size, orientation and margins
A4 is the default and suits most documents outside North America; Letter is for US and Canadian paper. The page is created at the chosen size and the captured HTML is scaled to the printable width, so proportions are kept and nothing is stretched.
Auto orientation stays portrait for ordinary pages and uses landscape when the capture is wider than it is tall. It does not choose a different orientation per page; the whole document is captured once and split. Pick portrait or landscape yourself for fixed layouts.
Margins of 0, 10 or 20 mm add a blank border. The default stylesheet also gives the HTML body some padding, which keeps text off the paper edge. Capture scale controls sharpness: at 2x an A4-width capture is about 1,588 pixels wide, which is better for small text but makes a larger file; 1x is quicker. The background colour fills transparent areas, and white is a safe default.
How the rendering works
The HTML is placed in a hidden, sandboxed iframe at A4 width with a baseline stylesheet: a system font, white background, readable line height, padded body, and sensible defaults for tables, images and headings. The tool waits for the iframe, images and web fonts where practical, then html2canvas captures the whole body as one tall image at 1x or 2x.
The image is cut into horizontal strips the height of the printable area and saved as JPEGs. pdf-lib puts one strip on each page, scaled to the printable width with its aspect ratio unchanged. Long documents become several pages; the final page is partly filled if the content does not divide evenly.
This is a browser screenshot, not a print engine. @page, break-before, break-after and @media print rules are ignored. Page breaks fall where the strips end, so a line or image can be cut across two pages. If exact breaks matter, use a proper print pipeline.
External images, fonts and CORS
The browser still fetches external images and fonts. An image from another server can appear in the preview yet fail the check for the PDF if that server does not allow cross-origin access. A browser can display such an image, but a canvas cannot read its pixels, so the tool stops before capture and explains the problem instead of producing a PDF with blank gaps. Data URLs are reliable because the image travels inside the HTML.
Web fonts have the same CORS requirement, and some will be substituted if they cannot be embedded. A system font stack is the safest choice. External resources also take time, so the tool stops waiting after a few seconds.
What is lost in the conversion
The pages are pictures, not text. You cannot select, search, copy or reflow the words, and screen readers cannot read them as prose. Links, buttons and form fields become part of the image and stop working. Animations, hover states, videos and other interactive content are not captured. Print-only styles and CSS page breaks are ignored, and small text can look soft at 1x.
Very wide fixed-width layouts are scaled down to the printable width, which can make their text small. Very long documents are captured as one image before slicing and can hit the browser's canvas limit; the tool warns when that is likely.
When to use HTML to PDF
Use it when a simple HTML page's appearance matters more than selectable text: a one-off invoice, quote, receipt, certificate or short report. It also works for a saved HTML email or a few notes you want to send as a file.
Avoid it for long manuals, accessible or searchable contracts, fillable forms, or pages that rely on JavaScript. For Word documents or spreadsheets, a format-specific converter preserves more structure. If the PDF is too large, compress it afterwards.
Privacy
The HTML is rendered and converted inside your browser. It is not uploaded to Lembog and no copy is stored on a server. External images and fonts are still requested from their own servers, just as on a normal web page; those hosts can see the request and your IP address. Embed images as data URLs and use system fonts for a self-contained file.
Related PDF tools
- JPG to PDF for turning images into pages.
- Merge PDF for combining the result with other documents.
- Compress PDF for making a large image-based PDF easier to send.
HTML to PDF FAQ
Does the PDF keep text selectable?
No. Each page is a JPEG, so text cannot be selected, searched or read by a screen reader. Use the browser's Print to PDF or a text-based converter if that matters.
Why can't my external images be included?
Usually the image is cross-origin without CORS headers. The preview can show it, but the tool cannot read it, so conversion stops with a message. Use a data URL or a server that sends the right headers.
Can I convert a page built with JavaScript?
No. Scripts are disabled, so only markup present in the HTML is rendered. Save the finished page or paste the generated HTML instead.
Do CSS page breaks and @page rules work?
No. One tall screenshot is sliced into pages. @page, break-before, break-after and @media print are ignored, and content can be cut at the slice point.
Which page size should I choose?
A4 for most of the world, Letter for US or Canadian paper. Match the printer if you will print it. Auto orientation is fine for normal documents; choose explicitly for fixed layouts.
Why is the PDF so large?
It holds one JPEG per page, at 2x by default. Use 1x, shorten the document, or compress the result with Compress PDF.
Is my HTML uploaded to Lembog?
No. It stays in your browser. External images and fonts are fetched from their own servers, which may see your request.