How to turn an HTML file or website into a PDF
Quick answer
To turn an HTML file or web page into a PDF, open it in a browser, choose Print, and save the print as a PDF instead of sending it to a printer. Chrome on a computer and on Android, and Safari on a Mac and an iPhone, have this built in, per Google's and Apple's help. The PDF keeps the text, images, and links and none of the page's scripts, so send a link when the page has buttons or a form.
Free plan: no credit card, 1 published page.
On this page
You have an HTML file, or a page open in a browser, and someone wants a PDF: to print, to file, or to attach to an email. A browser makes one through its Print command. This guide gives the steps per device, the print CSS for a PDF that comes out wrong, and what to do with a site of several pages.
The Google, Microsoft, Apple, and MDN pages quoted here were read on November 15, 2026. The print CSS was tested the same day in headless Chromium 156. We didn't open each browser's print window by hand, so a label on yours can differ from the help page's.
Save an HTML page as a PDF in 4 steps
1. Open the page in a browser
For a file on a computer, open it in a browser (Windows, Mac). For a page on the web, open its address. On a phone, a tapped .html file often opens in a preview that isn't a browser; see iPhone or Android first.
2. Open Print
Press Ctrl + P on Windows or Linux, or ⌘ + P on a Mac. In Chrome on a phone, Print is under Share.
3. Choose PDF instead of a printer
Pick Save as PDF where the printer is chosen. The exact spot per browser is in the sections below.
4. Save, then open the PDF
Name the file and save it. Open it once and scroll to the last page before you send it: a cut table or a missing background shows up here, and the print CSS below fixes both.
Chrome and Edge on a computer
Chrome. Google's help gives these steps: "Open the page, image, or file you want to print", then "Click File Print", or use the shortcut, Ctrl + p on Windows and Linux and ⌘ + p on a Mac. "In the window that appears, select the destination and change your preferred print settings." The destination to pick is Save as PDF: Google's help names that button in its Google Drive steps ("Click Save as PDF"). Google's page doesn't describe the other settings in that window.
Edge. Microsoft's help lists 3 ways to open Print: Ctrl + P on Windows or Command + P on a Mac; the 3-dot menu, then Print; or a right-click on the page, then Print. It says to "choose the printer you want to use" and doesn't name the PDF entry in that list. It does describe the settings that matter for a PDF, all under More settings:
- Background graphics: "to include the web page background in your print output or leave it unchecked to ignore the background". Microsoft's tip: "If the print preview or output looks different from the web page you're printing, you should include the background graphics."
- Headers and footers: "adds the current date to the document header & adds the page number to the footer". Untick it for a clean page.
- Margins: Default, None, Minimum, or Custom.
- Scale: "Fit to printable area", "Actual size", or a custom percentage.
Firefox. Mozilla's help page, How to print web pages in Firefox, answered our reader with a bot check on November 15, 2026, so this guide quotes no Firefox labels.
Safari on a Mac
Apple's Mac User Guide gives one route for any document you can print on a Mac. In Safari, the open webpage is the document:
- "Choose File > Print."
- "Click the PDF button or click the down arrow to open the PDF pop-up menu, then choose Save as PDF."
- "Enter a name and choose a location for the PDF file."
Apple adds that Security Options in the same window can "require passwords for opening the document, copying from the document, and printing the document". The same PDF menu has Send in Mail, which attaches the PDF to a new message. Apple's Safari User Guide has no page of its own on printing today.
iPhone and iPad
Safari on iPhone. Apple's iPhone User Guide saves a webpage as a PDF through Markup, not Print:
- Open the webpage, tap the Page Menu button, then tap Share. With the tab bar set to Bottom or Top, tap the Share button.
- "Tap Markup, then use the tools to annotate the webpage."
- Tap the Done button, "then choose Save File To".
- "Enter a name for the file, then tap Save."
Safari on iPad. Tap the Share button, tap View More, then Markup; finish with the Done button and Save File To.
Chrome on iPhone or iPad. Google's help: "At the top right, tap Share", then "View more" and Print, which prints through AirPrint. Google doesn't say how to save a PDF from that screen.
Android
Google's steps for Chrome on Android:
- "At the top right, tap More", then Share.
- "Select Print."
- "At the top, select a printer." Then: "To save your print preview as a PDF, tap Save as PDF."
- "Choose where to save the PDF file on your device."
To change paper size or orientation first, Google says to "tap the Down arrow".
Browsers compared
| Browser | Where Print is | How the PDF is chosen | Source |
|---|---|---|---|
| Chrome, computer | File, then Print; Ctrl + P or ⌘ + P | "Select the destination"; Save as PDF | Google Chrome Help |
| Edge, computer | 3-dot menu, then Print; Ctrl + P or Command + P; right-click | "Choose the printer you want to use"; Microsoft doesn't name the PDF entry | Microsoft Support |
| Safari, Mac | File, then Print | The PDF button, then Save as PDF | Apple Mac User Guide |
| Safari, iPhone | Page Menu button, then Share | Markup, Done, then Save File To | Apple iPhone User Guide |
| Chrome, iPhone | Share, View more, then Print | Google doesn't say | Google Chrome Help |
| Chrome, Android | More, Share, then Print | "Tap Save as PDF" | Google Chrome Help |
| Firefox | Not read | Not read | Mozilla's page didn't load for us |
When the PDF looks wrong
A browser lays the page out again for paper. Each problem below has a fix in the print window or in the page's CSS.
Backgrounds and colours are missing
A browser is allowed to change colours for paper. MDN describes the default: "when printing, a browser might opt to leave out all background images and to adjust text colors". In our test, headless Chromium's PDF dropped every background colour until backgrounds were switched on.
- In the print window: tick the background setting. Edge calls it Background graphics.
- In the page: set
print-color-adjust: exact. In our test this kept the colours with the background setting off. MDN is careful here: any option the browser gives the user "will take priority", and "there isn't any guarantee thatprint-color-adjustwill do anything".
A table, card, or chart is cut across two pages
Add break-inside: avoid to the element. MDN: it "avoids any break (page, column, or region) from being inserted within the principal box". In our test, 2 of 6 coloured boxes were split across pages without it and none with it. To start a section on a new page, break-before: page "forces a page break right before" the element. Older pages use page-break-inside, which MDN says browsers treat as an alias.
Menus and buttons end up in the PDF
Hide them for print only. MDN: styles inside @media print "will only be used for printed content".
The print CSS to paste
Put this at the end of the page's <style> block, or ask the AI that made the page to add it:
@media print {
nav, button, .no-print { display: none; }
tr, figure, .card { break-inside: avoid; }
h2 { break-before: page; }
body { print-color-adjust: exact; }
}
@page { size: A4; margin: 15mm; }
We ran this block in headless Chromium 156 on a test page with a menu, a button, 2 headings, a 4-row table, a card, and a figure. The menu left the PDF, no row or box was cut, the second h2 started a new page (2 pages became 3), and the background colours stayed with the background setting off. Change the selectors to your page's own, and delete the h2 line if you don't want a page per section. The block keeps each table row whole; a table longer than a page still breaks between rows.
@page sets the paper: MDN says it changes "the page's dimensions, orientation, and margins". Write size: A4 landscape for a wide table. MDN marks @page as newly available across browsers since December 2024, with parts that vary, so check the result in the browser you print from. In our headless test the A4 size applied only when the tool was told to prefer the page's CSS size. Edge's print window has its own Paper size setting under More settings.
Images or styles are missing
A PDF shows what the browser showed. If the page's images or CSS sit in separate files and the .html file was moved away from them, they're missing on screen and in the PDF alike. Why an HTML file is missing its images and styles has the fixes; reload the page and check it before printing.
A whole website vs one page
Print saves the page that is open, in one PDF. A site of several pages has no single Print for all of them:
- A few pages. Save each one, then join them. On a Mac, Apple's Preview guide says to open the PDFs, "choose View > Thumbnails", and "drag the thumbnails you want to add from the sidebar of one PDF to the sidebar of the other PDF".
- One long page instead. If you made the site, or an AI did, ask for a single-page version: "Put every page of this site into one HTML page, one section per page, with
break-before: pageon each section for printing." Then print once. - Many pages, or the same job every week. Use a script. Playwright's
page.pdf()"generates a pdf of the page with print css media"; it's what we used for the tests on this page. That takes someone who writes code.
Content that is closed stays closed: in our test, the inside of a closed <details> element wasn't in the PDF and an open one was. Open what you need before you print.
When a link is better than a PDF
A PDF from a browser holds the page's text, images, and links. In our headless Chromium test, the PDF kept a link as a link and the text as text, and held no script and no form field, so nothing that runs survives:
| The page has | In the PDF | At a link |
|---|---|---|
| Text, images, a table | Kept | Kept |
| Links | Kept, in our Chromium test | Kept |
| Buttons, tabs, a calculator, a quiz | Frozen as they looked when printed | Work |
| A form | A picture of its fields; no form field in our test | Works as the page wrote it |
| Later corrections | A new PDF to send again | The same link shows the new version |
So print a PDF when someone needs a fixed copy: an invoice, a report to file, a handout. Send a link when they need to use the page.
For a link, drop the file into the upload box at the top of this page and click Get my preview link. You get a link without an account, with scripts off, for 3 minutes; it's for checking the page. Click Keep this page — free, no card and sign up, then click Publish page, choose Public, click Next, and the first time, click Publish free. The page goes live at its own address with its scripts running. Convika takes one .html or .htm file up to 2 MB, and a dropped folder or zip puts the CSS and images the page names inside it. It runs no server code and doesn't make PDFs: the person who opens the link prints it from their own browser, with the steps above.
On Free the page is Public and carries the Convika bar, and nothing hides the bar when the page is printed. Pro ($12 a month) removes it and adds private links and passwords.
If the page is a form or report your team fills in and each person saves their own PDF, one link for a report template staff fill in and save as PDF covers that setup.
Frequently asked questions
How do I turn an HTML website into a PDF?
Open the page in a browser, open Print (Ctrl + P, or ⌘ + P on a Mac), choose Save as PDF as the destination, and save. That makes one PDF per page. For a site of several pages, save each page and join the PDFs, or put the pages into one long HTML page first.
How do I convert an HTML file to PDF without software?
Use the browser you already have. Double-click the .html file so it opens in a browser, then print it to PDF. On a Mac, Apple's steps are File, Print, the PDF button, then Save as PDF.
How do I save a web page as a PDF on an iPhone?
In Safari, Apple's iPhone User Guide says to tap the Page Menu button, tap Share, tap Markup, then tap the Done button and choose Save File To. Name the file and tap Save. Chrome on iPhone has Share, View more, Print; Google's help doesn't say how to save a PDF from there.
How do I save a web page as a PDF on Android?
In Chrome, tap More, then Share, then Print. At the top, select a printer and tap Save as PDF, then choose where to save the file, as Google's Chrome help describes.
Why are the background colours missing in my PDF?
A browser can leave backgrounds out of a print; headless Chromium did in our test. Turn on the background setting in the print window (Edge calls it Background graphics), or add print-color-adjust: exact to the page's CSS. In the same test the CSS kept the colours by itself; MDN warns there is no guarantee a browser honours it.
How do I stop a table from splitting across pages in the PDF?
Add tr { break-inside: avoid; } inside an @media print block, so a break falls between rows and not through one. In our headless Chromium 156 test, a row that was cut in two without it stayed whole with it. A table longer than one page still breaks between rows.
Do buttons and forms work in the PDF?
No. In our headless Chromium test, the printed PDF held the text and a working link, and no script and no form field. A button looks like a button and does nothing. If people need to click, type, or submit, publish the page and send its link.
Can I turn a PDF back into the HTML page?
Not into the page you had. The printed PDF holds the result on paper, without the page's scripts. Keep the .html file; it's the original.
Sources
- Print from Chrome (Google Chrome Help), its Computer, Android, and iPhone & iPad tabs (no date on the page; read November 15, 2026)
- Print in Microsoft Edge (Microsoft Support) (no date on the page; read November 15, 2026)
- Save a document as a PDF on Mac (Apple, Mac User Guide) (read November 15, 2026)
- Annotate and save a webpage as a PDF in Safari on iPhone (Apple, iPhone User Guide) and on iPad (read November 15, 2026)
- Combine PDFs in Preview on Mac (Apple, Preview User Guide) (read November 15, 2026)
- Printing (MDN) (last modified November 7, 2025; read November 15, 2026)
@page(MDN) (last modified September 12, 2026; read November 15, 2026)break-inside(MDN) andbreak-before(MDN) (both last modified April 20, 2026; read November 15, 2026)print-color-adjust(MDN) (last modified November 12, 2026; read November 15, 2026)- Page:
pdf()(Playwright docs) (read November 15, 2026)
Next step
How to password protect an HTML page or website
A JavaScript password script leaves the password in the page source. To password protect an HTML page or link, encrypt the file or let a server check it.
Related articles
- One link for an HTML report template staff fill in and save as PDFPublish the HTML report template as a page and send one link. Each person fills it in on their phone and saves their own PDF, and nobody overwrites anyone else.
- How to share an HTML file as a link that opens on any phoneUpload the file to a host and send its link; email and Google Drive send the code. 8 hosts compared, from Netlify Drop to Convika, with 4 steps.
- My HTML file opens but the images and styling are missing. Why?An .html file is only the page: its images, style.css, scripts, and fonts are other files. Our October 2026 tests show what goes missing, and how to fix each.
- How to Send an HTML File by Email (Gmail, Outlook, or Link)Gmail and Outlook let you attach .html files, though work filters can block them and mail apps may show code. Or publish it and email a link instead.
- How do I open an HTML file on iPhone in Safari, and send one that opens?Open an .html file on iPhone in Safari: save it to Files, open a free HTML viewer, and choose it so its scripts run. The Files preview ran none in our test.
- How do I open an HTML file in Chrome mobile on Android, and send one that opens?Open an HTML file in Chrome mobile on Android: tap it in Files, choose Chrome, and tap Just once. HTML Viewer ran no scripts in our test. Or use a free viewer.
Skipbox
Cheap & fast GitHub Actions runners, unlimited for $39 a month
Your own machine keeps Docker layers and package caches between jobs. Switch by changing one runs-on line.
Start a free Skipbox trial