Skip to content

HTML to PDF

Turn a web address, an HTML file, or pasted code into a PDF.

Your browser fetches each address directly, so the site has to allow it. If a fetch fails, save the page as an .html file and use Convert HTML files.

Drag this link to your bookmarks bar: Save as PDF then click it on any page to open this tool with that page’s address filled in.

About HTML to PDF

To convert HTML to PDF, this tool turns a web page, an .html file or pasted HTML code into a PDF, entirely in your browser: it renders the page off-screen at the width you choose and saves what it looks like as a PDF, with web links still clickable. The pages of the PDF are pictures of that render, so the text in them cannot be selected or searched.

Reach for it to archive a page, send someone a copy of it, or keep a record of how a page looked on a given day. A site that blocks cross-origin fetching, or content that only appears after you interact with the page, will not come through this way. The page’s own JavaScript is never run either, so a page that builds itself with scripts may come out empty.

How it works

  1. Open the tool: it starts on the options screen with its three tabs and the Convert URL to PDF tab ready. The "Save as PDF" bookmark described below opens it the same way with the address already filled in.
  2. Choose a tab: Convert URL to PDF (web addresses, one per line, starting with https://), Convert HTML files (click Add .html files) or HTML code (paste the markup). Switching to the URL or HTML code tab replaces any .html file you added.
  3. Open More options to set page size, orientation, margins, viewport width and a delay before capture.
  4. Click Convert to PDF.
  5. Download the PDF, or a ZIP when converting more than one page.
  6. If a web address fails, save that page as an .html file from your browser (Ctrl or Cmd+S) and add it on the "Convert HTML files" tab instead.

What gets rendered, and what does not

The HTML is drawn in a hidden frame with scripting switched off, captured as one large picture, and cut into PDF pages. That suits pages that arrive as finished HTML, such as articles, documentation and receipts. Pages assembled by JavaScript, such as single-page apps and dashboards, typically come out empty or show only an "enable JavaScript" notice.

The pages are JPEG pictures at 90% quality, captured at 1.5 times the on-screen size. Links are the one live element: an address that begins with http becomes clickable over the right spot, while relative links, mailto: links and #anchor links do not.

Pasted code and uploaded files are drawn on their own, so a relative address inside them, such as an image src of "photo.png", is looked for on this site rather than on the site it came from, and is not found. Only the URL tab supplies the page’s address as a base. To keep a picture in a file or snippet, embed it as a data: address.

Web addresses, CORS and the bookmark

In the URL tab, your browser fetches each address directly, so the site has to allow it. Many sites do not let other websites read their pages, a rule called CORS, and for those the fetch fails. Any failed fetch, including a missing page or a network problem, shows the same message about CORS. No login cookies are sent, so a page behind a sign-in comes back as it would to a stranger, or fails.

Even when the page arrives, each image is drawn only if its own server allows it; a refused image is left as a gap. The "Save as PDF" bookmark saves typing and nothing more: drag its link from under the tabs to your bookmarks bar, and clicking it on any page opens this tool with that address in the URL tab. Only the address travels, not the page or your session, so the same CORS rule applies.

Saving the page from your browser and adding the .html file gets past the block on the page itself, but the saved file still refers to its pictures and stylesheets by address or through a folder you are not adding, so it may look plainer.

Options that change the result

All of these sit under More options.

  • Page size: One long page (the default), A4, Letter, Legal or Custom size (width and height in mm). One long page is a single page as wide as the viewport and as tall as the whole capture. The fixed sizes cut the capture at set heights, which can slice through a line of text or an image, and Orientation and Margins (None, Small at 10 mm or Normal at 20 mm) appear only for them.
  • Viewport width (px): 1280 by default, from 320 to 2560. It sets the width the page lays itself out at (390 gives a phone-style layout). On a fixed size that whole width is shrunk to the page, so with no margin 16 px body text is about 7 pt on A4 at 1280 and about 12 pt at 800.
  • Use print stylesheet: off by default. When ticked, the page’s @media print rules are applied to the render, but stylesheets loaded from another website cannot be inspected and are skipped.
  • Hide cookie notices: on by default. It hides any element whose id or class contains "cookie" or "consent", and any whose class contains "gdpr". That can catch more than a banner, so untick it if part of a page goes missing.
  • Delay before capture (seconds): 0 to 10, default 0. A pause after the page has loaded, for slow web fonts and background images. It does not make scripts run.

Frequently asked questions

Related tools

This tool ran entirely in your browser and nothing was uploaded. Your Recent files list keeps a copy of local files under 5 MB until you clear it. How your files are handled.