How to Save a Chromium Webpage Screenshot as a PDF
Choose print-to-PDF for a paginated webpage or capture the rendered pixels and convert the image to PDF. Here are the Chromium commands and tradeoffs.
To save a Chromium webpage as a conventional PDF, use Chromium’s print-to-PDF output. To preserve the page as screenshot pixels inside a PDF, capture an image first and convert that image to PDF. These are separate operations: --print-to-pdf creates a PDF from the page’s print layout, while --screenshot writes an image.
Choose the output you actually need
| Goal | Use | What you get |
|---|---|---|
| A paginated document, often with selectable text | Print to PDF | A PDF rendered using the webpage’s print layout |
| The visible rendered page appearance as pixels | Screenshot, then image-to-PDF conversion | A PDF containing the captured image; conversion details depend on your OS or document software |
Use print-to-PDF unless you specifically need the screenshot’s pixel appearance. Printing may paginate content and use print-specific styles; it is not a screenshot embedded in a PDF.
Save a webpage directly as PDF with Headless Chromium
Run Chrome or Chromium with --headless --print-to-pdf. The documented default output filename is output.pdf in the current working directory:
chrome --headless --print-to-pdf https://developer.chrome.com/
For Chromium installations whose executable is named chromium, use that command name instead:
chromium --headless --print-to-pdf https://developer.chrome.com/
Omit the browser’s generated print header and footer with --no-pdf-header-footer:
chrome --headless --print-to-pdf --no-pdf-header-footer https://developer.chrome.com/
The current documented flag is --no-pdf-header-footer. Older Chrome versions may require --print-to-pdf-no-header instead. Check the version’s command-line support if the current flag is rejected.
Wait for the page to render
Use --timeout to set the maximum wait before capture. For example, this waits up to five seconds:
chrome --headless --timeout=5000 --print-to-pdf https://developer.chrome.com/
The timeout is a ceiling, not proof that all content has loaded. A slow site or asynchronously loaded content may need a longer wait. Inspect the PDF before sharing it.
Save a screenshot-style PDF
First capture the page to an image. Chromium documents this headless screenshot command:
chrome --headless --screenshot --window-size=412,892 https://developer.chrome.com/
This writes screenshot.png in the current working directory. The window size controls the capture viewport; this command alone does not establish that the image covers the full page.
Next, use an image-to-PDF function available in your operating system or document software to place the PNG in a PDF and save it. The exact menus and steps depend on that software. This workflow preserves the captured pixels, but the result may be a single image-derived page rather than a paginated, selectable-text document.
Control PDF layout in automation
When driving Chromium through the DevTools Protocol, the printToPDF operation accepts options for common layout decisions. The available controls include:
landscapefor page orientationprintBackgroundto include background graphicsscaleto scale printed contentpaperWidthandpaperHeightfor page dimensionsmarginTop,marginBottom,marginLeft, andmarginRightpageRangesto select pagesdisplayHeaderFooterand header/footer templates
These are protocol automation parameters; do not assume every desktop print dialog uses the same labels or exposes every control. See the [DevTools Protocol Page.printToPDF reference](https://chromedevtools.github.io/devtools-protocol/tot/Page/#method-printToPDF) for parameter definitions.
Check the result
- Open the generated PDF and confirm the intended content appears.
- Check page breaks, orientation, margins, and scaling for print-to-PDF output.
- Check that the page’s backgrounds appear if they matter to the result.
- For screenshot-style output, confirm the image dimensions and that the captured viewport includes the content you need.
- For dynamic pages, verify that asynchronously loaded content was present before distributing the file.
Or skip the browser setup
ScreenshotNeo can return a PDF from one API request. See the [ScreenshotNeo API docs](https://screenshotneo.com/docs/) for request options.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -d format=pdf -o page.pdf
import requests
r = requests.get(
"https://api.screenshotneo.com/v1/shot",
params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com", "format": "pdf"},
timeout=90,
)
r.raise_for_status()
open("page.pdf", "wb").write(r.content)
const q = new URLSearchParams({
access_key: 'YOUR_API_KEY',
url: 'https://stripe.com',
format: 'pdf'
});
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
if (!res.ok) throw new Error(`ScreenshotNeo returned ${res.status}`);
await import('node:fs/promises').then(fs => fs.writeFile('page.pdf', Buffer.from(await res.arrayBuffer())));
ScreenshotNeo accepts cookie and consent banners like a visitor and removes 60+ known consent platforms, newsletter popups, and chat widgets before capture; each of those steps can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits cost nothing, and response headers identify the page verdict and billing status. Its MCP server lets AI agents use take_screenshot, get_page_info, and capture_pdf. The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000. [Learn about ScreenshotNeo](https://screenshotneo.com) or [sign up free](https://screenshotneo.com/account/sign-up/).
Troubleshooting
| Symptom | Likely cause | What to try |
|---|---|---|
| No PDF appears | The command ran from a different working directory, or the browser command is not installed under that name. | Check the command name and look for output.pdf in the process’s current working directory. |
| Header or footer is present | Print headers and footers are enabled. | Pass --no-pdf-header-footer; on an older version, try --print-to-pdf-no-header. |
| Content is missing from the PDF | The page had not finished rendering before the capture, or content loads asynchronously. | Increase --timeout, then inspect the output. A maximum wait cannot guarantee that a site’s own asynchronous work is complete. |
| The PDF breaks differently than the screen | Print-to-PDF follows print layout and pagination rather than preserving the screen as pixels. | Adjust paper size, margins, orientation, or scale where your workflow exposes them. If exact pixels are required, capture an image and convert it to PDF. |
| The screenshot image is only part of the page | --window-size sets a viewport and does not itself establish full-page capture. |
Use a workflow that captures the required page area, then convert that image to PDF. |
| The background is absent | Print output may omit background graphics. | Enable background printing in the print workflow; in DevTools Protocol automation, inspect the printBackground option. |
Performance, reliability, and cost
Headless capture avoids the need to interact with a visible browser, but capture time depends on the target page and how long it takes to render. The documented --timeout sets the maximum wait, so choose a value appropriate for the site and check output when content is dynamic.
Chromium’s built-in commands perform the documented screenshot and PDF operations locally; the research sources give no relevant price or performance benchmarks. For recurring or multi-URL API capture, ScreenshotNeo offers a usage API, caching with a chosen TTL, async jobs with signed webhooks, and bulk capture of up to 100 URLs per call. Its plans are Free (1,000 per month), Starter ($5 for 3,000), Growth ($15 for 15,000), Pro ($39 for 60,000), Scale ($99 for 250,000), and Business ($249 for 1,000,000); yearly billing gives two months free, and every feature is on every plan.
FAQ
Will a print-to-PDF file look exactly like a screenshot?
No. It is a PDF rendered from the page’s print layout. Capture an image and convert that image to PDF when preserving screenshot pixels is the requirement.
Does the screenshot command create a PDF?
No. --screenshot writes an image file; a separate image-to-PDF step is needed for a screenshot-style PDF.
Can I choose specific pages in an automated PDF?
The DevTools Protocol printToPDF includes a pageRanges option. The Headless CLI examples cited here do not document a corresponding command-line page-range flag.
Are desktop browser menu names and shortcuts covered here?
No. Exact visible-browser controls vary, and the references used here verify Chromium’s command-line and protocol workflows rather than current platform-specific menu sequences.


