Skip to content

Instantly share code, notes, and snippets.

@adityapatadia
Created July 25, 2020 06:40
Show Gist options
  • Save adityapatadia/acc5e20a51dfdd8d3a5d837b798692db to your computer and use it in GitHub Desktop.
Save adityapatadia/acc5e20a51dfdd8d3a5d837b798692db to your computer and use it in GitHub Desktop.
HTML to PDF conversion using Puppeteer
async function printPDF(html){
const browser = await puppeteer.launch({headless: true, args: ["--no-sandbox=true"]});
const page = await browser.newPage();
await page.setContent(html);
const pdf = await page.pdf({ format: 'A4' });
await browser.close();
return pdf
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment