chromedp icon indicating copy to clipboard operation
chromedp copied to clipboard

Guidance needed: How to reliably download PDF files using chromedp

Open Strong-Foundation opened this issue 11 months ago • 0 comments

Hello chromedp team,

I’m currently working on a project where I need to download PDF files using chromedp. However, when navigating directly to a PDF URL, the browser opens the PDF inline in the viewer instead of triggering a download event. This means I cannot capture the PDF file through the typical browser.EventDownloadProgress or similar download-related events.

I’ve tried approaches such as:

Using browser.SetDownloadBehavior to enable downloads and specify a download folder Injecting an anchor tag with the download attribute and programmatically clicking it to force a download

Despite these efforts, I haven’t found a reliable way to trigger and track PDF downloads headlessly.

Could you please provide guidance, best practices, or an example on how to properly download PDF files (or other inline-displayed resources) using chromedp?

For testing purposes, here is a publicly accessible sample PDF URL: https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf

Thank you very much for your time and assistance!

Best regards, Strong Foundation

Strong-Foundation avatar May 19 '25 12:05 Strong-Foundation