mirror of
https://github.com/frappe/books.git
synced 2024-12-24 20:00:29 +00:00
Link bootstrap css in puppeteer for generating pdf
This commit is contained in:
parent
058011ebe9
commit
9fdc94bd93
@ -10,6 +10,9 @@ async function makePDF(html, filepath) {
|
|||||||
const browser = await puppeteer.launch();
|
const browser = await puppeteer.launch();
|
||||||
const page = await browser.newPage();
|
const page = await browser.newPage();
|
||||||
await page.setContent(html);
|
await page.setContent(html);
|
||||||
|
await page.addStyleTag({
|
||||||
|
url: 'https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css'
|
||||||
|
})
|
||||||
await page.pdf({
|
await page.pdf({
|
||||||
path: filepath,
|
path: filepath,
|
||||||
format: 'A4'
|
format: 'A4'
|
||||||
@ -17,9 +20,9 @@ async function makePDF(html, filepath) {
|
|||||||
await browser.close();
|
await browser.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getPDFForElectron(doctype, name, destination) {
|
async function getPDFForElectron(doctype, name, destination, htmlContent) {
|
||||||
const { shell } = require('electron');
|
const { shell } = require('electron');
|
||||||
const html = await getHTML(doctype, name);
|
const html = htmlContent || await getHTML(doctype, name);
|
||||||
const filepath = path.join(destination, name + '.pdf');
|
const filepath = path.join(destination, name + '.pdf');
|
||||||
await makePDF(html, filepath);
|
await makePDF(html, filepath);
|
||||||
shell.openItem(filepath);
|
shell.openItem(filepath);
|
||||||
|
Loading…
Reference in New Issue
Block a user