I'd like to automate the download of some pdf bill in a specific directory but I didn't manage to do it.
Note i'm using puppeteer 3.0.2 on windows:
I tried to setup it multiple ways : Initializing the browser:
const browser = await puppeteer.launch({
headless: navMode,
userDataDir : "E:/projets/factures/",
args: [
'--start-maximized',
// you can also use '--start-fullscreen'
]
});
I also tried:
await page._client.send('Page.setDownloadBehavior', {behavior: 'allow', downloadPath: 'E:/projets/factures/'});
juste before the download
i tried also :
page.on('request', req => {
if (req.url() === urlFile) {
const file = fs.createWriteStream('./file.pdf');
https.get(req.url(), response => response.pipe(file));
}
});
all of this is before :
await page.goto(urlFile); //urlFile contains the pdf url
The PDF is only downloading in the Default Download Directory