I've been trying to download a PDF file using headless chrome. What I got to do is send a form with some info, on form submit it should download a PDF. How do I save this PDF? Obs: I'm using NodeJS as the framework.
The documentation says: Puppeteer is a Node library which provides a high-level API to control Chrome or Chromium over the DevTools Protocol. Puppeteer runs headless by default, but can be configured to run full (non-headless) Chrome or Chromium. It's basically a browser which you can run from Node.
I do not know exactly how the pdf is downloaded but I think you can use the following.
await page._client.send('Page.setDownloadBehavior', {behavior: 'allow', downloadPath: '/home/me/stuff'});
And then check for the file to be in the directory specified in the downloadPath property.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With