Skip to content

Instantly share code, notes, and snippets.

@moltar
Created May 17, 2019 13:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moltar/4749a2bf18b6cc61ae2985219fd76113 to your computer and use it in GitHub Desktop.
Save moltar/4749a2bf18b6cc61ae2985219fd76113 to your computer and use it in GitHub Desktop.
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