Skip to content

Commit 3d89248

Browse files
authored
Merge pull request #26 from piyushverma001/master
Fixed issue of style tag
2 parents 4c5757c + 3d021e7 commit 3d89248

File tree

3 files changed

+915
-57
lines changed

3 files changed

+915
-57
lines changed

index.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const puppeteer = require('puppeteer');
22
var Promise = require('bluebird');
33
const hb = require('handlebars')
4-
4+
const inlineCss = require('inline-css')
55
module.exports
66
async function generatePdf(file, options, callback) {
77
// we are using headless mode
@@ -20,10 +20,11 @@ async function generatePdf(file, options, callback) {
2020
const page = await browser.newPage();
2121

2222
if(file.content) {
23+
data = await inlineCss(file.content, {url:"/"});
2324
console.log("Compiling the template with handlebars")
2425
// we have compile our code with handlebars
25-
const template = hb.compile(file.content, { strict: true });
26-
const result = template(file.content);
26+
const template = hb.compile(data, { strict: true });
27+
const result = template(data);
2728
const html = result;
2829

2930
// We set the page content as the generated html by handlebars
@@ -61,10 +62,11 @@ async function generatePdfs(files, options, callback) {
6162
const page = await browser.newPage();
6263
for(let file of files) {
6364
if(file.content) {
65+
data = await inlineCss(file.content, {url:"/"})
6466
console.log("Compiling the template with handlebars")
6567
// we have compile our code with handlebars
66-
const template = hb.compile(file.content, { strict: true });
67-
const result = template(file.content);
68+
const template = hb.compile(data, { strict: true });
69+
const result = template(data);
6870
const html = result;
6971
// We set the page content as the generated html by handlebars
7072
await page.setContent(html, {

0 commit comments

Comments
 (0)