Created
July 25, 2020 06:40
-
-
Save adityapatadia/acc5e20a51dfdd8d3a5d837b798692db to your computer and use it in GitHub Desktop.
HTML to PDF conversion using Puppeteer
This file contains 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
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