How to convert an HTML file to a PDF (and when a link is better)
Every browser can turn an HTML page into a PDF with no extra software. The steps on each device, the fixes for the usual print problems, and what a PDF loses compared with sending the page as a link.
You do not need a converter site to turn an .html file into a PDF. The browser you already have does it through its print dialog, and the file never leaves your computer. Open the page, print it, and pick PDF as the destination.
On a computer
First open the .html file in a browser: drag it onto a browser window, or see opening an HTML file in Chrome. Then:
- ✓Chrome and Edge: press Ctrl+P (Cmd+P on a Mac). Set Destination (Printer in Edge) to Save as PDF, then click Save.
- ✓Safari: choose File, then Export as PDF. Or press Cmd+P, open the PDF menu at the bottom of the dialog and choose Save as PDF.
- ✓Firefox: press Ctrl+P or Cmd+P, set Destination to Save to PDF, then click Save.
On a phone
Phones often will not open an .html file from storage as a page at all. See opening an HTML file on iPhone and on Android; once the page is at a web address, the steps above work.
- ✓iPhone or iPad: open the page in Safari, tap Share, then Print. Pinch outward on the page preview to open it as a PDF, then tap Share again and Save to Files.
- ✓Android: open the page in Chrome, tap the three-dot menu, Share, then Print. Choose Save as PDF at the top and tap the PDF button.
Fix the usual print problems
The PDF is a print of the page, so print rules apply. Check the preview before saving.
- ✓Colours and shaded boxes are missing: browsers drop background colours when printing. In the print dialog open More settings and tick Background graphics (Print backgrounds in Firefox and Safari). To fix it in the file, add print-color-adjust: exact to the coloured elements.
- ✓A table row or chart is cut across two pages: add break-inside: avoid to the element in the page CSS. To force a new page before a section, use break-before: page.
- ✓The layout is the phone version: print uses the paper width, which is narrower than a laptop window. Switch Layout to Landscape, or lower Scale until the desktop layout fits.
- ✓A date, file path and page number appear in the margins: untick Headers and footers.
- ✓Wrong paper size: set Paper size in the dialog, or put @page { size: A4; margin: 15mm; } in the CSS.
- ✓The file name is wrong: Chrome suggests the page <title> as the PDF name. Change the title in the file or rename on save.
From the command line
For a report that is regenerated often, headless Chrome writes the PDF without a dialog: chrome --headless --print-to-pdf=report.pdf report.html. Use the full path to the Chrome program on your system, and a file:/// or https:// address for the page.
What a PDF loses
A PDF is a snapshot of the page at the moment you printed it. That is the point for an invoice or a signed-off report. It costs you on anything interactive.
- ✓Charts keep their picture and lose hover values, filters and zoom.
- ✓Tabs, accordions and menus print in whatever state they were in. Hidden tabs are not in the PDF.
- ✓Video, audio and animation do not carry over. Links do stay clickable.
- ✓A wide dashboard is squeezed to paper width or split over pages.
- ✓Each correction means a new file to send, and the old copy stays in inboxes.
When a link is the better send
If the page is interactive, or likely to change, send the page itself. With FileShare Pro you upload the .html file and get an https:// link that opens as the working page on any device, with no account needed to view it.
- ✓People can comment on the page itself without signing up.
- ✓You can replace the file and keep the same link, so nobody holds an old version.
- ✓The document view has a "Print or save as PDF" button in the top bar (in the ... menu on a phone). It opens the page on its own in a new tab and starts the print dialog, so anyone who wants a PDF copy can still make one.
- ✓If you already have the PDF, you can share the PDF as a link too.
Try it
Keep the PDF for records and send the link for reading. Sign up free, upload the .html file and you have both. For reports that go to clients every month, see sending a client report as a link.
Frequently asked
Open the .html file in Chrome, Edge, Safari or Firefox, press Ctrl+P or Cmd+P, choose Save as PDF as the destination and save. No extra software or upload is needed.
Browsers leave out background colours when printing. Tick Background graphics in the print dialog, or add print-color-adjust: exact to the coloured elements in the page CSS.
No. Links stay clickable, but charts, tabs, filters, video and animation become a still picture. Send the page as a link when people need those to work.
Open the page in Safari, tap Share, then Print, pinch outward on the preview to open it as a PDF, then tap Share and Save to Files.
Drop the file, copy the link — live in seconds, free plan included.
Start sharing free