Your files never leave your device. All processing happens locally in your browser.
How do I turn HTML code into a PDF in my browser without uploading it to a server?
Open the HTML to PDF tool, paste or type your HTML into the code box (or pick a Blank, Invoice, Résumé, Letter or Report template), and watch the live preview render as you type. Choose a page size (A4, Letter, Legal or A3) and a margin (None, Small, Normal or Wide), give the file a name, then press Convert to PDF. The tool renders your markup off-screen with html2canvas and builds a multi-page PDF with pdf-lib, entirely in your browser — then downloads it as name.pdf. Nothing is ever uploaded: the HTML, the render and the PDF all stay on your device.
Paste HTML or start from a Blank, Invoice, Résumé, Letter or Report template, with a live preview that updates as you type
Pick page size (A4, Letter, Legal, A3) and margin (None, Small, Normal, Wide), and set the output file name
Renders the markup with html2canvas and assembles the PDF with pdf-lib, splitting tall content across pages automatically
Runs 100% in the browser — no upload, server or account — and downloads as name.pdf
Honest scope: the PDF pages are rendered images, so the text is not selectable or searchable, and only inline/embedded CSS is captured reliably
What is
HTML to PDF Conversion
HTML to PDF conversion turns a fragment of HTML markup — with its inline CSS styling, tables, headings and images — into a fixed-layout PDF document that looks the same in every viewer and prints consistently. Unlike raw HTML, which reflows and can render differently across browsers, devices and screen widths, a PDF freezes the layout, fonts, colours and page breaks so an invoice, résumé or report always appears exactly as intended. This tool performs the conversion client-side: it drops your HTML into an off-screen container sized to the chosen page width, rasterises it to a canvas with the html2canvas library, then embeds the resulting image into PDF pages with pdf-lib, slicing long content across A4, Letter, Legal or A3 sheets. Because the page is captured as an image, the output is a faithful visual copy of the rendered markup rather than a re-flowable, text-selectable document — the trade-off for pixel-accurate fidelity with no server round-trip.
PDF Tools
Related terms
HTMLPDFCSShtml2canvaspdf-libmarkup to PDFwebpage to PDFinvoice PDFrésumé PDFclient-sideA4Letterpage sizemarginraster PDFconvert HTML
Frequently Asked Questions
No. Your HTML is rendered and turned into a PDF entirely in your browser, so nothing is uploaded — there is no server, account or tracking.
Nothing leaves your device. When you press Convert to PDF, the tool writes your markup into a hidden container on the page, captures it with the html2canvas library running in your own browser, and builds the PDF on-device with pdf-lib, handing it back from a local Blob for download. No bytes are sent anywhere. That matters because the things people convert — invoices with client details, résumés, contracts, internal reports — are often private. There is no login, no telemetry and no CDN in the processing path, the tool keeps working offline once the page is cached, and closing the tab discards everything.
Yes for inline and embedded CSS — colours, fonts, tables, borders, spacing and images render faithfully. Very modern CSS, external fonts and cross-origin images can be limited.
The converter renders your markup the way a browser would and then photographs the result, so inline styles and embedded <style> rules — colours, backgrounds, fonts, tables, borders, padding and layout — are captured accurately; that is why the Invoice, Résumé and Report templates come out looking polished. Because it uses the html2canvas engine, there are honest limits: some cutting-edge CSS features may not paint exactly, web fonts must have loaded, and images hosted on other domains only appear if their server allows cross-origin reads (the tool requests them with CORS). For the most reliable output, keep your CSS inline in the markup and use data-URI or same-origin images.
No — the pages are rendered as images, so the text is not selectable or searchable. That is the trade-off for pixel-perfect visual fidelity with no server.
This is the most important thing to know about client-side, screenshot-style conversion. The tool rasterises your rendered HTML to a canvas and embeds that image into the PDF, so what you get is a faithful picture of the page rather than a live text layer. The upside is that the layout, fonts and styling are reproduced exactly as they looked; the downside is that you cannot highlight, copy, search or re-flow the text, and file size is that of an image-based PDF. If you specifically need selectable, searchable text, a browser Print-to-PDF (Ctrl/Cmd+P → Save as PDF) or a server-side Chromium renderer preserves the text layer, at the cost of some layout control and privacy.
It is completely free with no account or watermark. Choose A4, Letter, Legal or A3, a None/Small/Normal/Wide margin, and start from five built-in templates.
HTML to PDF is free with no sign-up, watermark or limit, and because it is 100% client-side it works in any modern browser on Android, iPhone, iPad, Windows, macOS or Linux with nothing to install. You can start from scratch or load one of five templates — Blank, Invoice, Résumé, Letter and Report — then edit the HTML with a live preview beside it. Set the page size to A4, Letter, Legal or A3 and the margin to None, Small, Normal or Wide, name the output file, and convert. Content taller than one page is automatically split across multiple pages. One document is processed at a time and the whole render is held in browser memory, so an extremely long or heavy document is bounded by your device’s RAM.
Detailed Explanation
📖How It Works
Turning HTML Markup Into a PDF in the Browser
HTML to PDF converts a piece of HTML markup — with its inline styling, tables, headings and images — into a downloadable, fixed-layout PDF, and it does the whole job in your browser without sending anything to a server. On the /html-to-pdf page you paste or type HTML into a code editor, or load one of five starter templates (Blank, Invoice, Résumé, Letter, Report), and a live preview beside the editor renders the markup as you type. You choose a page size (A4, Letter, Legal or A3) and a margin (None, Small, Normal or Wide), name the output file, and press Convert to PDF. The tool drops your markup into an off-screen container sized to the exact page width, rasterises it with the html2canvas library at 2× scale, and assembles a multi-page PDF with pdf-lib, splitting content taller than one page across successive sheets. The finished document downloads as name.pdf. Because the render and the PDF build both run on-device, the markup and the file never leave the tab.
Paste HTML or start from Blank, Invoice, Résumé, Letter or Report templates, with a live preview
Choose page size (A4, Letter, Legal, A3) and margin (None, Small, Normal, Wide) and name the file
Renders with html2canvas and builds the PDF with pdf-lib, auto-splitting tall content across pages
Runs entirely in the browser — no upload, server or account — and downloads as name.pdf
📋Use Cases
When to Reach for HTML to PDF
A PDF freezes a layout so it looks and prints the same everywhere, which is exactly what you want for documents you send or archive. Common uses are turning a hand-coded or exported HTML invoice into a clean PDF to email a client; rendering a styled résumé or cover letter from HTML into a print-ready file; producing a formatted report, statement or receipt from templated markup; and capturing a snippet of styled HTML — a pricing table, a certificate, an email design — as a fixed document for sharing or printing. The built-in Invoice, Résumé, Letter and Report templates give you a professional starting point you can edit inline. Because the conversion is client-side, you can generate PDFs from markup that contains client names, pricing, personal contact details or internal figures without uploading any of it to a third-party service. Reach for a different approach when you need the PDF text to stay selectable and searchable, or when the source is a full external web page with heavy scripts and cross-origin assets rather than a self-contained block of styled HTML.
Invoices, résumés, cover letters, reports, statements and receipts from HTML markup
Client-side, so markup with private details is never uploaded
Best for self-contained styled HTML; full external pages with scripts are a different job
🔧Technical Details
How the Conversion Works
When the page loads at /html-to-pdf it renders the HtmlToPdf component (src/pages/tools/pdf/HtmlToPdf.tsx), a self-contained React view. Your markup lives in a textarea whose value also drives a live preview rendered with dangerouslySetInnerHTML. On Convert to PDF, the tool dynamically imports html2canvas and pdf-lib, creates a fixed off-screen <div> positioned far off the viewport, sets its width to the chosen page’s point width and its padding to the selected margin, injects your HTML as innerHTML, and waits briefly for the browser to lay it out and load images. html2canvas then captures that container to a canvas at 2× scale with a white background and useCORS enabled so permitted cross-origin images are included. To paginate, the code computes the canvas height that corresponds to one page (page height ÷ page width × canvas width) and loops over each slice: it draws that slice onto a temporary canvas, exports it as a JPEG at 0.92 quality, embeds the JPEG into a pdf-lib document with embedJpg, adds a page at the exact point dimensions (A4 595×842, Letter 612×792, Legal 612×1008, A3 842×1191) and draws the image to fill it. Finally PDFDocument.save() serialises the bytes, which are wrapped in an application/pdf Blob and downloaded as your file name with a .pdf extension.
Markup is injected into an off-screen container sized to the page width plus the chosen margin
html2canvas captures it to a canvas at 2× scale with useCORS for permitted cross-origin images
The canvas is sliced by page height and each slice is embedded as a JPEG via pdf-lib embedJpg
Pages use exact point sizes (A4/Letter/Legal/A3); PDFDocument.save() produces the downloaded Blob
⚠️Limitations
Honest Limitations
The defining trade-off is that this is screenshot-style conversion: html2canvas paints your rendered HTML onto a canvas and that image is embedded into the PDF, so the pages are pictures, not live text. The layout, fonts and styling are reproduced faithfully, but the resulting PDF text is not selectable, searchable or re-flowable, and the file is sized like an image-based PDF. Second, html2canvas re-implements a subset of CSS rather than using the full browser engine, so most inline and embedded styles paint correctly but some cutting-edge CSS features may not render exactly, and web fonts must already be loaded for the page. Third, images hosted on other domains only appear if their server returns permissive CORS headers; same-origin and data-URI images are safest. Fourth, the markup is inserted as static HTML — any <script> is not executed, so JavaScript-generated content will not appear. Fifth, page breaks are computed by slicing the captured image at fixed page heights, so a slice can fall in the middle of a line or element rather than at a natural break. Finally, one document is rendered at a time and the whole capture is held in browser memory, so a very tall or heavy document is bounded by your device’s RAM. For selectable text or perfect modern-CSS fidelity, a browser Print-to-PDF or a server-side Chromium renderer is the alternative.
Pages are rendered images, so the PDF text is not selectable, searchable or re-flowable, and files are image-sized
html2canvas supports a subset of CSS; some modern features may not paint, and web fonts must be loaded
Cross-origin images need permissive CORS headers; scripts in the markup are not executed
Page breaks are cut at fixed page heights and can split a line; one document at a time, bounded by RAM
🔒Privacy & Security
Privacy: Your Markup Never Leaves the Tab
The documents people build from HTML — invoices carrying client names and pricing, résumés with personal contact details, contracts, statements and internal reports — are often confidential, so uploading the markup to a cloud converter just to produce a PDF would be self-defeating. This tool never does. Your HTML lives in the page as you type, and on Convert it is rendered into a hidden container, captured with html2canvas in your own browser, and assembled into a PDF on-device with pdf-lib; the file is handed back from a local Blob for download. There is no server, upload, database, logging, API or account anywhere in the processing path, and no telemetry. The libraries are bundled with the app rather than loaded per-conversion from a third party, the tool keeps working offline once the page is cached, and closing the tab discards the markup and the generated file. The only optional network use anywhere on the site is consent-gated advertising, which never sees your content — a real contrast with cloud HTML-to-PDF services that require sending them the very markup you were trying to keep private.
HTML is rendered and converted to PDF entirely in the browser; nothing is uploaded
No server, upload, database, API or account in the processing path, and no telemetry
Works offline once cached; closing the tab discards the markup and the generated PDF
Only optional network use on the site is consent-gated advertising, which never sees your content
HTML to PDF — how it converts and where it stops
Capability
Support
Notes
Input
Pasted HTML or a template
Type or paste markup, or load Blank, Invoice, Résumé, Letter or Report; live preview updates as you type
CSS fidelity
Inline & embedded CSS
Colours, fonts, tables, borders, spacing and images render; some modern CSS may not, and web fonts must be loaded
Page setup
A4, Letter, Legal, A3 + margins
Choose page size and a None/Small/Normal/Wide margin; tall content is auto-split across pages
Text layer
Image-based (not selectable)
Pages are rasterised with html2canvas, so the PDF text cannot be selected, searched or re-flowed
Images & scripts
Same-origin/data-URI; no JS
Cross-origin images need CORS; <script> in the markup is not executed
Output
name.pdf
A multi-page PDF built with pdf-lib and downloaded from a local Blob (default document.pdf)
Privacy & scale
In-browser, bounded by RAM
Rendered and built on-device, one document at a time; 100% client-side, no upload
HTML to PDF converts a block of HTML markup into a fixed-layout PDF entirely in the browser: html2canvas rasterises your rendered HTML and pdf-lib assembles it into A4, Letter, Legal or A3 pages with your chosen margin, downloaded as name.pdf. Inline and embedded CSS — colours, fonts, tables and images — is reproduced faithfully, but because the pages are rendered images the PDF text is not selectable or searchable; some modern CSS may not paint, cross-origin images need CORS, and scripts are not run. Everything is client-side with nothing uploaded, one document at a time, bounded by device RAM.