From d7fede965dd3f96e466df22df25f29b59e345a0c Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Fri, 30 Mar 2018 00:21:56 +0530 Subject: [PATCH] Pdf generation based on puppeteer --- server/pdf.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 server/pdf.js diff --git a/server/pdf.js b/server/pdf.js new file mode 100644 index 00000000..3d1f39c4 --- /dev/null +++ b/server/pdf.js @@ -0,0 +1,12 @@ +const puppeteer = require('puppeteer'); + +module.exports = async function (html, filepath) { + const browser = await puppeteer.launch(); + const page = await browser.newPage(); + await page.setContent(html); + await page.pdf({ + path: filepath, + format: 'A4' + }); + await browser.close(); +}