How to Download a Webpage as a PDF: Beginner's Guide

2025-10-24 07:47:03 zaki zou

How to Download a Webpage as a PDF on Windows

Sometimes you come across a webpage you want to keep, but copying or saving it directly isn’t allowed. In such cases, saving the webpage as a PDF is a great solution. It lets you access the page offline anytime and even edit or highlight the content later. In this guide, you’ll explore three easy ways to download a webpage as a PDF — using built-in browser features, online tools, and code-based methods.

Download Webpage as PDF with the Built-in Feature

When you need to save a webpage as a PDF, most people’s first instinct is to use the browser’s built-in download feature. It’s the quickest and most convenient way to get the job done. However, the steps can vary slightly depending on your operating system. Let’s take a look at how to download a webpage as a PDF on the two most common platforms — Windows and macOS.

Download a Webpage as a PDF on Windows

  • Press Ctrl + P to open the print dialog.

How to Download a Webpage as a PDF on Windows

  • In the Printer drop-down list, select Microsoft Print to PDF or Save as PDF (the name may differ depending on your browser).
  • Click Print to continue.
  • When the file dialog appears, choose a destination folder and click Save.
  • If your Windows version doesn’t include Microsoft Print to PDF, you can still use Chrome’s built-in Save as PDF option to download the webpage as a PDF.

Download a Webpage as a PDF on macOS

  • Press Command + P to open the print window.

How to Download a Webpage as a PDF on Mac

  • At the lower-left corner, click the PDF drop-down menu and select Save as PDF.
    • In Chrome, you can also choose Open PDF in Preview to view it before saving.
  • When prompted, select a location to save the file and confirm.

How to Download a Webpage as a PDF with Online Tools

Besides the built-in shortcut keys on your computer, you can also use online tools to save a webpage as a PDF. These tools are convenient because they don’t require installation, work on any device (computers, laptops, and mobile phones), and can quickly process different types of web content. The steps are simple — just search for “HTML to PDF” or “Download webpage as PDF” in your browser. In the example below, we’ll use iLovePDF, one of the most popular tools for this purpose.

  • Go to the official iLovePDF website and find the HTML to PDF tool.
  • Click the Add HTML button, then enter the URL of the webpage you want to save in the pop-up window. After confirming that everything is correct, click the red Add button at the bottom right.
    Download a Webpage as a PDF with Online Tools
  • Next, adjust the settings in the right-hand panel as needed, then click Convert to PDF. Once the conversion is complete, you can download the PDF file to your computer.

How to Download a Webpage as a PDF with Code

In addition to the two common methods mentioned above, you can also perform this task using code — a more flexible option designed for developers. This approach offers several advantages that the previous methods don’t, such as batch downloading, full offline operation, and better automation for large-scale tasks.

In this tutorial, we’ll use Spire.Doc for Python to demonstrate how to download a webpage as a PDF. As a professional Python library, it allows developers to handle everything from simple document format conversions to advanced tasks like content editing and encryption.

Steps to download an entire webpage as a PDF in Python:

  • Install Spire.Doc using the command pip install spire.doc. You’ll also need to install requests, a library used for fetching webpage content.

  • Import the required modules:

from spire.doc import *
from spire.doc.common import *
import requests
# Get HTML content from the webpage
url = "/Tutorials/Python/Spire.Doc-for-Python/Program-Guide/Conversion/Python-Convert-HTML-to-PDF.html"
html = requests.get(url).text
  • Write the HTML content into a Word document:
# Write HTML to a Word document
doc = Document()
section = doc.AddSection()
paragraph = section.AddParagraph()
paragraph.AppendHTML(html)
  • Finally, save the document as a PDF file:
# Save the document as a PDF
doc.SaveToFile("E:/Administrator/Python1/webpage_to_pdf11.pdf", FileFormat.PDF)

Here's the complete code example:

from spire.doc import *
from spire.doc.common import *
import requests

#  HTML Get HTML from web
url = "/Tutorials/Python/Spire.Doc-for-Python/Program-Guide/Conversion/Python-Convert-HTML-to-PDF.html"
html = requests.get(url).text

# Write HTML to document
doc = Document()
section = doc.AddSection()
paragraph = section.AddParagraph()
paragraph.AppendHTML(html)

# Save the document to PDF file
doc.SaveToFile("E:/Administrator/Python1/webpage_to_pdf11.pdf", FileFormat.PDF)
doc.Close()

Below is a preview of the resulting PDF file: How to Download a Webpage as a PDF in Python

If you save a webpage in HTML format, Spire.Doc can also easily convert it to a PDF using the Document.SaveToFile() method.

The Conclusion

This article introduced three different ways to download a webpage as a PDF. Depending on your needs, you can choose the method that works best for you — whether it’s using built-in features, online tools, or the Spire.Doc Python library. If you want to explore more advanced PDF features, consider trying Spire.Doc’s 30-day free license to experience its full potential.


ALSO READ