Created
March 28, 2022 18:41
-
-
Save fforres/2b0b7f32d0ab6ce94c9bb9264091c1f9 to your computer and use it in GitHub Desktop.
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
import puppeteer from "puppeteer" | |
async function generatePdf(htmlContent) { | |
const browser = await puppeteer.launch({ headless: true }); | |
const page = await browser.newPage(); | |
await page.setContent(htmlContent); | |
const pdf = await page.pdf({ format: 'A4' }); | |
const pdfBuffer = await page.pdf(); | |
await page.close(); | |
await browser.close(); | |
return pdfBuffer; | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment