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

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

To save a PDF download in Puppeteer, set downloadBehavior to { policy: 'allow', downloadPath: '/absolute/writable/path' } before triggering it. Then check the destination directory yourself: Puppeteer does not provide a high-level download-completion promise, and a PDF navigation may still open Chrome’s viewer depending on how the server responds and which browser mode you use.

Configure downloads in Puppeteer

Current Puppeteer exposes downloadBehavior as a generic browser option. Give it an explicit, absolute directory path and use the allow policy. The directory must already exist or be creatable by your application, and the browser process must have permission to write there.

import puppeteer from 'puppeteer';

const downloadPath = '/absolute/path/to/downloads';
const browser = await puppeteer.launch({
  downloadBehavior: {
    policy: 'allow',
    downloadPath,
  },
});

try {
  const page = await browser.newPage();
  await page.goto('https://example.com/file.pdf');
  // A navigation completing does not prove that a download completed.
  // Check the directory and validate the completed file in your application.
} finally {
  await browser.close();
}

Replace the sample URL and directory with values for your workflow. Configure the behavior before opening the PDF link or clicking a download control; applying it afterward may be too late for that download.

Free tools Windows power users keep installed

One-click scans. No signup required.

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

The documented Puppeteer API pages identify the generic options as version 25.12.0 and the DownloadBehavior type as version 25.10.0. Those are API-page versions, not a guarantee about the version installed in your project. Check the types and documentation matching your installed Puppeteer release if an option is rejected or behaves differently. Browser mode and Chrome version also matter.

#1 Best Overall
PDF Reader for Fire Tablet
  • PDF Reader for Fire Tablet
  • ✔Fast PDF Viewer
  • ✔Simple List of PDF Files
  • ✔Share and Print PDF
  • ✔55 Different Themes

Choose the right policy and filename behavior

Puppeteer’s download behavior offers policies including allow and allowAndName; both require downloadPath. With allow, Chrome can use the filename supplied by the download. With allowAndName, Chrome names files using download GUIDs, so use it only if your application can map those identifiers to the files it expects.

Policy What it means for your script
allow Allow downloads into the required downloadPath; generally the more convenient choice when the original filename matters.
allowAndName Allow downloads into the required path but name them with download GUIDs; your workflow may need to identify the resulting file another way.
deny Do not allow downloads.
default Use the browser’s default download behavior rather than explicitly allowing downloads.

The policy names and path requirement are defined by Puppeteer’s DownloadBehavior API and Chrome DevTools Protocol (CDP). Avoid assuming that changing the policy will rename a PDF response or force every inline PDF to become a download.

When to use browser-level CDP

For ordinary Puppeteer scripts, start with the surfaced downloadBehavior option. Use Chrome’s browser-level CDP command, Browser.setDownloadBehavior, when you need direct protocol control, such as setting a policy for a particular browser context or enabling download events. That method accepts deny, allow, allowAndName, and default; the path is required for the two allow policies.

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.
Rank #2
PDF Reader, PDF Viewer, PDF Editor- file document
  • Fast PDF reader with read aloud, night mode, reading mode, search and bookmarks
  • Highlight, underline, draw, add notes and text on any PDF
  • Fill PDF forms, sign documents with your finger and protect PDFs with a password
  • Convert PDF to Word or JPG; merge, extract and reorder pages; scan with your camera
  • Works on Fire TV: send PDFs from your phone over Wi-Fi and read them on the big screen

If Puppeteer is connected to an already-running browser, configure the behavior for the appropriate connection or browser context rather than assuming a new launch option will affect that existing session. CDP supports a browser-context identifier, so context scope is important when a browser has more than one context. Confirm the protocol support in the Chrome and Puppeteer versions you actually run.

Older examples may use the Page-domain Page.setDownloadBehavior. It is a separate protocol method. Prefer Puppeteer’s surfaced option or the browser-level method when supported by your versions, and check the protocol reference before adopting an older snippet.

Detect completion and validate the file

Puppeteer’s file guide says it does not currently offer a high-level programmatic API for handling file downloads. Do not treat page.goto() resolving, a click completing, or a PDF viewer appearing as proof that a file is ready. Build completion detection into your application.

Rank #3
My PDF Reader
  • Open PDF files easily on your smartphone.
  • Cool User Interface and look.
  • Zoom and pan easily by using gesture with your fingers.
  • Scroll through pages easily vertically.
  • Fullscreen viewing capability.
  1. Prepare the destination. Create the directory before launch, use an absolute path, and verify that the browser process can write to it.
  2. Trigger the download only after configuration. Apply the policy at launch or through the relevant connection/context before navigation or click.
  3. Wait for a completed file. Poll the directory or use an application-level file-watching strategy. Treat temporary or partial files as in progress; do not consume a file until writing has finished.
  4. Identify the expected file. If multiple downloads may occur, use a unique destination per job or correlate the download event and resulting path. GUID-based names require an explicit mapping strategy.
  5. Validate the result. Check that the final file exists, has a plausible nonzero size, and contains the content your application expects. Handle timeouts and cleanup of incomplete files.

The exact completion strategy depends on your operating system, concurrency model, and download naming rules. A small delay alone is not a reliable completion signal: slow responses and large PDFs can outlast it, while fast failures can make it appear sufficient.

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

Why a PDF may still open in Chrome

downloadPath tells Chrome where to put files that are downloaded; it does not necessarily convert a response that Chrome treats as an inline PDF into a download. The cited Puppeteer and CDP API documentation describes download policies, but does not promise that the setting changes every PDF URL that Chrome would otherwise render in its viewer.

When you control the server, serving the response as an attachment is a common way to request download behavior. If you do not control it, retrieving the response bytes through an application-controlled HTTP path may be more predictable, provided your authentication, cookies, redirects, and access rules are handled correctly. These are implementation approaches, not guarantees that every site will permit or deliver the file in the same way.

Rank #4
PDF Viewer Plus, pdf reader
  • View pdf files
  • Merge Pdf files
  • Compress pdf files
  • Night mode
  • Snap to page

Also distinguish a viewer from a navigation failure. Puppeteer’s Page API warns that headless: 'shell' does not support navigation to a PDF document. If PDF navigation fails in that mode, changing the download directory may not address the underlying limitation. Test with the browser mode and exact Chrome/Puppeteer versions used in deployment.

Troubleshooting

Symptom Likely cause What to check
No file appears The browser cannot write to the directory, policy was not set before the trigger, or the response was rendered inline rather than downloaded. Use an absolute writable path, configure before the action, and inspect how the URL is served.
Directory or path error The directory does not exist, is relative to a different working directory, or lacks permissions. Create it before launch, resolve it to an absolute path, and test write access as the browser process user.
Script continues before the file is ready Navigation or click completion was mistaken for download completion. Wait for filesystem completion and validate the final file; Puppeteer has no high-level download promise.
Unexpected filename allowAndName uses GUID-based names, or the server provided a different filename. Use allow if the original name suits the workflow, or implement an explicit correlation/mapping step.
PDF opens in the viewer The server/browser handled the response as inline PDF content. Check the response behavior; if you control the server, request attachment delivery. Otherwise consider retrieving bytes through an application-controlled HTTP path.
PDF navigation fails in headless shell The selected headless: 'shell' mode does not support PDF document navigation. Test in a supported browser mode or use a retrieval flow that does not navigate to the PDF document.
Option or behavior differs from an example The installed Puppeteer, Chrome, or CDP version differs from the documented API version. Check the installed package types and the matching protocol/API reference; do not assume an older Page-domain snippet applies.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If your goal is to capture a webpage as an image or PDF rather than exercise a Puppeteer download workflow, ScreenshotNeo provides a screenshot API and MCP server. It accepts a URL in one request and returns a PNG, JPEG, WebP, or PDF. Its clean-shot flow accepts cookie/consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; those steps can be turned off. Bot checks/CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing status. An MCP server offers take_screenshot, get_page_info, and capture_pdf for AI agents.

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

Install the Python requests package, replace the key with your API key, and save the response:

import requests

r = requests.get(
    "https://api.screenshotneo.com/v1/shot",
    params={"access_key": "YOUR_API_KEY", "url": "https://example.com"},
    timeout=90,
)
open("shot.webp", "wb").write(r.content)

See the ScreenshotNeo API documentation for request options. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000. Sign up for 1,000 free screenshots a month with no card.

Best Value
PDF Reader For Fire Tablet & Ebook Reader, Viewer, Editor, Convertor, Merge, Split & Compress
  • Fast & Smooth PDF Reader – Open, view, and read PDF files with ease.
  • Dark Mode Support – Comfortable reading experience at night.
  • Quick Search & Bookmarking – Find text and save favorite pages instantly.
  • Annotate & Edit PDFs – Highlight, underline, and add comments.
  • Merge & Split PDFs – Combine or separate pages easily.

Frequently Asked Questions

Does setting a download path force every PDF to download?

No. It controls files Chrome treats as downloads; it does not guarantee that an inline PDF response will stop opening in the viewer.

Can I wait for a Puppeteer download promise?

Puppeteer does not currently document a high-level download-handling API, so your application must detect and validate the completed file.

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

Does this work in headless shell mode?

Puppeteer’s Page API warns that headless shell does not support navigation to a PDF document; that limitation is separate from download-path configuration.

Quick Recap

Bestseller No. 1
PDF Reader for Fire Tablet
PDF Reader for Fire Tablet
PDF Reader for Fire Tablet; ✔Fast PDF Viewer; ✔Simple List of PDF Files; ✔Share and Print PDF
$2.99
Bestseller No. 2
PDF Reader, PDF Viewer, PDF Editor- file document
PDF Reader, PDF Viewer, PDF Editor- file document
Fast PDF reader with read aloud, night mode, reading mode, search and bookmarks; Highlight, underline, draw, add notes and text on any PDF
$6.85
Bestseller No. 3
My PDF Reader
My PDF Reader
Open PDF files easily on your smartphone.; Cool User Interface and look.; Zoom and pan easily by using gesture with your fingers.
Bestseller No. 4
PDF Viewer Plus, pdf reader
PDF Viewer Plus, pdf reader
View pdf files; Merge Pdf files; Compress pdf files; Night mode; Snap to page; Horizontal View
Bestseller No. 5
PDF Reader For Fire Tablet & Ebook Reader, Viewer, Editor, Convertor, Merge, Split & Compress
PDF Reader For Fire Tablet & Ebook Reader, Viewer, Editor, Convertor, Merge, Split & Compress
Fast & Smooth PDF Reader – Open, view, and read PDF files with ease.; Dark Mode Support – Comfortable reading experience at night.
$2.99

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.