October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk5 min

How to Save a Webpage as a PDF from a URL Automatically

Save a webpage as a PDF automatically with a Chrome command or browser automation code. Compare methods, control rendering, and troubleshoot incomplete PDFs.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For a one-off conversion, run Chrome Headless with --print-to-pdf and the URL. For repeatable automation, use Puppeteer or Playwright to control navigation, wait for rendering, and save the generated PDF. Both browser APIs use print styling by default, so check the result if you need it to look like the screen.

Choose the right method

Use case Method Trade-off
A shell command or batch job with few custom requirements Chrome Headless Direct invocation, with timeout and virtual-time options; layout customization is less convenient than with a page API. Chrome Headless documentation.
A Node.js script that uses Chrome Puppeteer page.pdf() Programmatic navigation and PDF options; print CSS is the default. Puppeteer PDF generation.
An existing Playwright automation or test project Playwright page.pdf() Returns a PDF buffer and uses print CSS by default. Playwright Page API.

None of these methods guarantees that every site has finished rendering at a particular wait condition. Pages with dynamic content, delayed images, or unusual print styles need validation against the PDF output.

As an Amazon Associate I earn from qualifying purchases.

Save a URL as PDF with Chrome Headless

Install Chrome or Chromium and make the executable available as chrome on your command line. Run:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
chrome --headless --print-to-pdf https://example.com/

Chrome saves the PDF in the current working directory; the documented default filename is output.pdf. To control the destination, pass an output path:

#1 Best Overall
Sale
Seagate 2TB Portable Hard Drive | USB 3.0 (STGX2000400) | Everyday HDD storage. Plug-and-play backup. Windows & macOS. Adobe CC trial included. 1-Year Warranty
  • Easily store and access 2TB to content on the go with the Seagate Portable Drive, a USB external hard drive
  • Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop
  • To get set up, connect the portable hard drive to a computer for automatic recognition no software required
  • This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
  • The available storage capacity may vary.
chrome --headless --print-to-pdf=./output/page.pdf https://example.com/

Chrome’s command-line reference documents --print-to-pdf and the current-directory default in its Headless command-line reference.

Control capture timing and headers

  • --no-pdf-header-footer omits Chrome’s print header and footer.
  • --timeout=5000 caps the wait before capture at the specified number of milliseconds.
  • --virtual-time-budget=42000 advances time-dependent page code before capture.

These numbers are examples, not universal wait recommendations. A timeout limits waiting; it does not prove that all content is ready. Choose timing for the target page and inspect the resulting PDF.

Generate PDFs in Node.js with Puppeteer

Install Puppeteer in a Node.js project with npm install puppeteer. This complete script navigates to a URL, waits for network activity to settle, writes a PDF, and closes the browser even if capture fails:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Seagate Portable 1TB External Hard Drive HDD – USB 3.0 for PC, Mac, PlayStation, & Xbox, 1-Year Rescue Service (STGX1000400) , Black
  • Easily store and access 1TB to content on the go with the Seagate Portable Drive, a USB external hard drive.Specific uses: Personal
  • Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop. Reformatting may be required for Mac
  • To get set up, connect the portable hard drive to a computer for automatic recognition no software required
  • This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
  • The available storage capacity may vary.
const puppeteer = require('puppeteer');

(async () => {
  const browser = await puppeteer.launch();
  try {
    const page = await browser.newPage();
    await page.goto('https://example.com/', { waitUntil: 'networkidle2' });
    await page.pdf({ path: 'page.pdf' });
  } finally {
    await browser.close();
  }
})();

networkidle2 is the wait condition shown in Puppeteer’s guide; a page that polls continuously or loads content later may need a different strategy. Puppeteer PDF generation waits for fonts by default and uses print CSS. See the Puppeteer PDF generation guide and Page.pdf() API.

Generate PDFs with Playwright

Install Playwright and its browser dependencies following the Playwright installation guide. The following Node.js example saves the PDF buffer returned by page.pdf():

const { chromium } = require('playwright');
const fs = require('node:fs/promises');

(async () => {
  const browser = await chromium.launch();
  try {
    const page = await browser.newPage();
    await page.goto('https://example.com/', { waitUntil: 'networkidle' });
    const pdf = await page.pdf({ path: 'page.pdf' });
    await fs.writeFile('page.pdf', pdf);
  } finally {
    await browser.close();
  }
})();

The path option writes the PDF to a file; the method also returns a buffer, which can be sent to another part of an application instead. Playwright’s PDF output uses print CSS by default. Consult the Page API for available PDF options.

Rank #3
UnionSine 1TB Ultra Slim Portable External Hard Drive HDD-USB 3.0
  • 【Upgraded version】 - The mirror logo strip is combined with the striped non-slip design. The rounded corners of the shell are more suitable for holding. The strips play a heat dissipation function to ensure a stable and fast transmission process.
  • 【Ultra-thin and quiet】 - The motherboard adopts JMicron 578 noise-free solution, giving you a quiet working environment. Lightweight and portable size designed to fit in your pocket for easy portability.
  • 【Ultra-Fast Data Transfers】 - Pairing this external hard drive with JMicron 578 solution USB 3.0 and USB 2.0 interfaces enables blazing-fast data transfer. It boasts theoretical read speeds of up to 125MB/s and write speeds of up to 103MB/s.
  • 【Plug and Play】 - With no software to install, just plug it in and the drive is ready to use.The hard disk chip is wrapped with an aluminum anti-interference layer to increase heat dissipation and protect data.
  • 【What You Get】 - 1 x Portable Hard Drive, 1 x USB 3.0 Cable, 1 x User Manual, Gift-type shell packaging ,Three-year manufacturer's warranty and free technical support services.

Make the PDF resemble the screen

Puppeteer and Playwright generate PDFs using print CSS by default. This can change colors, hide elements, or rearrange layout compared with the page in a browser window. When screen styling matters, emulate screen media before generating the PDF:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
// Puppeteer
await page.emulateMediaType('screen');
await page.pdf({ path: 'page.pdf' });

// Playwright
await page.emulateMedia({ media: 'screen' });
await page.pdf({ path: 'page.pdf' });

For print-oriented output, check whether the site defines @media print rules and whether those rules suit the document you need. Print color adjustments can affect appearance; Puppeteer’s guide describes using CSS such as -webkit-print-color-adjust: exact when exact print colors are needed. Test representative pages rather than assuming one media mode works for every site. See the Puppeteer guide and Playwright API.

Validate the PDF before relying on it

Automated capture can finish successfully and still produce an incomplete or unattractive document. Check a sample from the actual target site, especially when pages contain delayed or interactive content.

Rank #4
Sale
WD 2TB Elements Portable External Hard Drive for Windows, USB 3.2 Gen 1/USB 3.0 for PC & Mac, Plug and Play Ready - WDBU6Y0020BBK-WESN
  • High capacity in a small enclosure – The small, lightweight design offers up to 6TB* capacity, making WD Elements portable hard drives the ideal companion for consumers on the go.
  • Plug-and-play expandability
  • Vast capacities up to 6TB[1] to store your photos, videos, music, important documents and more
  • SuperSpeed USB 3.2 Gen 1 (5Gbps)
  • Navigation: confirm the page reached the intended URL and did not stop on an error or challenge page.
  • Dynamic content: verify content loaded after initial navigation, including content revealed by scripts.
  • Fonts and images: check for missing fonts, blank image areas, or images that load only after scrolling.
  • Pagination: inspect page breaks, clipped sections, and very wide content.
  • Print behavior: compare print and screen media where visual fidelity matters; review headers, footers, colors, and hidden elements.

The browser documentation describes timing and media controls, but no universal wait condition or setting guarantees identical results on every website.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshooting common problems

The PDF is blank or misses content

The browser may have captured before the site rendered the needed content, or the page may require interaction. Increase or tailor the wait, use a selector-based readiness check in your automation, and inspect the page state before PDF generation. A longer timeout alone cannot guarantee readiness.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Chrome cannot find the command

Your Chrome executable may not be on the shell’s PATH or may have a different name. Run the command with the executable’s full path, or configure PATH for the environment running the job.

Best Value
Kosbees 500 GB External Hard Drives,Portable Hard Drive for Windows,Ultra Slim External HDD Store Compatible with PC, MAC,Laptop,PS4, Xbox one, Xbox 360;Plug and Play Ready
  • 【Plug-and-Play Expandability】 With no software to install, just plug it in and the drive is ready to use in Windows(For Mac,first format the drive and select the ExFat format.
  • 【Fast Data Transfers 】The external hard drives with the USB 3.0 cable to provide super fast transfer speed. The theoretical read speed is as high as 110MB/s-133MB/s, and the write speed is as high as 103MB/s.
  • 【High capacity in a small enclosure 】The small, lightweight design offers up to 500GB capacity, offering ample space for storing large files, multimedia content, and backups with ease. Weighing only 0.35 Lbs, it's easy to carry "
  • 【Wide Compatibility】Supports PS4 5/xbox one/Windows/Linux/Mac and other operating systems, ensuring seamless integration with game consoles,various laptops and desktops .
  • Important Notes for PS/Xbox Gaming Devices: You can play last-gen games (PS4 / Xbox One) directly from an external hard drive. However, to play current-gen games (PS5 / Xbox Series X|S), you must copy them to the console's internal SSD first. The external drive is great for keeping your library on hand, but it can't run the new games.

The page looks different from the browser

PDF generation uses print styles by default in Puppeteer and Playwright. Emulate screen media if you need screen styling, then check colors and page breaks. The site can also define its own print rules.

Headers or footers appear unexpectedly

For Chrome Headless, add --no-pdf-header-footer. In Puppeteer or Playwright, inspect the PDF options and the page’s print styles for the source of the extra content.

The script hangs or times out

Some sites keep network connections open or load resources indefinitely, so a network-idle condition may not be reached. Choose a wait condition appropriate for the target page, set a sensible timeout, and wait for a specific content signal when possible.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Or skip the browser setup

ScreenshotNeo offers a PDF response from one API request. Its clean-shot steps accept cookie or consent banners and remove more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and the response identifies the page verdict and billing status in headers. Its MCP server provides screenshot and PDF tools for AI agents.

Use the PDF format parameter shown in the ScreenshotNeo API documentation. For a cURL request:

curl -G "https://api.screenshotneo.com/v1/shot" 
  -d access_key=YOUR_API_KEY 
  --data-urlencode url=https://example.com 
  -d format=pdf 
  -o page.pdf

For example, 1,000 screenshots a month are free with no card; paid plans start at $5 for 3,000 shots. Sign up for free and get 1,000 screenshots a month with no card.

Quick Recap

SaleBestseller No. 1
Seagate 2TB Portable Hard Drive | USB 3.0 (STGX2000400) | Everyday HDD storage. Plug-and-play backup. Windows & macOS. Adobe CC trial included. 1-Year Warranty
Seagate 2TB Portable Hard Drive | USB 3.0 (STGX2000400) | Everyday HDD storage. Plug-and-play backup. Windows & macOS. Adobe CC trial included. 1-Year Warranty
This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable; The available storage capacity may vary.
$129.99
Bestseller No. 2
Seagate Portable 1TB External Hard Drive HDD – USB 3.0 for PC, Mac, PlayStation, & Xbox, 1-Year Rescue Service (STGX1000400) , Black
Seagate Portable 1TB External Hard Drive HDD – USB 3.0 for PC, Mac, PlayStation, & Xbox, 1-Year Rescue Service (STGX1000400) , Black
This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable; The available storage capacity may vary.
$119.80
SaleBestseller No. 4

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.