Created
May 17, 2019 13:33
-
-
Save moltar/4749a2bf18b6cc61ae2985219fd76113 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = async function pdf(url, req) { | |
const browser = await puppeteer.launch() | |
const page = await browser.newPage() | |
await page.goto( | |
'https://.....c9users.io/clients/' + | |
req.params.id + | |
'/reports/monthlyreport/' + | |
req.params.marketplace + | |
'/' + | |
req.params.month, | |
{ waitUntil: 'networkidle2' }, | |
) | |
//Original Code saving the file locally | |
// await page.pdf({ | |
// path: 'public/temp/Performance Report -' + req.params.month + '.pdf', | |
// format: 'A4', | |
// landscape: true, | |
// printBackground: true, | |
// }) | |
//Code I'm using for the buffer | |
const pdf = await page.pdf({ format: 'A4', landscape: true, printBackground: true }) | |
await browser.close() | |
return pdf | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment