mirror of
https://github.com/frappe/books.git
synced 2024-12-23 11:29:03 +00:00
Pdf generation based on puppeteer
This commit is contained in:
parent
555fcfeda8
commit
d7fede965d
12
server/pdf.js
Normal file
12
server/pdf.js
Normal file
@ -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();
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user