Node-html-pdf: Error: html-pdf: PDF generation timeout. Phantom.js script did not exit.

Created on 20 Jan 2017  路  12Comments  路  Source: marcbachmann/node-html-pdf

throws this error while genrating pdf using node.js on sails framework. Previously the same code was working fine, but have been getting this error since last 3 days.

var pdf = require('html-pdf');

var options = {
"format":"Letter" ,
"orientation": "portrait",
"footer":{
"height":"15mm"
},
"quality": "75",
"type":"pdf",
"timeout":60000
};
var file = 'assets/templates/invoice.ejs'
var html = ejs.render(fs.readFileSync(file, 'utf8'),{ 'data': params.data });
pdf.create(html,options).toFile('././invoice/' + params.title + '.pdf', function(err, result) {
if (err) {
return console.log("err", err);
}
if (callback != undefined) {
return callback(null, { 'fileName':params.title + '.pdf'});
}
return res.json({ 'fileName':params.title + '.pdf'});
});

I have already checked all the parameters and data being passed.

Most helpful comment

I ended up getting this fixed. You have to set the timeout parameter to a high value. My laptop ended up being too slow, resulting in it timing out with this error. Hopefully this helps!

pdf.create(html, { orientation: 'landscape', type: 'pdf', timeout: '100000' })

All 12 comments

A quick workaround (Not a fix) I ended up doing is extending the timeout in the options to 60 seconds. when executing the pdf generation to get rid of this issue.

I have the same issue when I run my code in a docker container. Outside of it, everything runs fine. I'm going to try to increase the timeout, but that seems like a workaround like @RabeaWahab said

Well: it does not fix the problem, I'll have to dig deeper

Getting same error when using in aws Lambda function.

Same here.

Ditto. Anyone have any insight into this problem?

I do have also the same problem using this library in Cloud Functions

I ended up getting this fixed. You have to set the timeout parameter to a high value. My laptop ended up being too slow, resulting in it timing out with this error. Hopefully this helps!

pdf.create(html, { orientation: 'landscape', type: 'pdf', timeout: '100000' })

I extended the timeout. Then the pdf could be generated but image from img html tag display blue question mark box. So i think extend the timeout could not really fix this problem.

2020 and I have the same mistake! There are times that it generates the pdf very fast, with a certain time of 3 seconds, and there are times that it is eternally processing, until the 120000ms timeout that I put has burst. Someone solved it?

Hello, i was faced with this error on the server(DMZ) but not locally on my machine,

Error: html-pdf: PDF generation timeout. Phantom.js script did not exit.

And after much research and debugging, all i needed to do was to comment out the link tag containing an attribute href=fonts.googleapis.com in my html

And it worked just fine afterwards.

This seems to be a problem with the html, my problem was that I had an image source linked to a deleted image in a server and that was what caused the time out, I solved it by putting the image in the server's route and that was it, I hope this to be useful to someone

Hello, i was faced with this error on the server(DMZ) but not locally on my machine,

Error: html-pdf: PDF generation timeout. Phantom.js script did not exit.

And after much research and debugging, all i needed to do was to comment out the link tag containing an attribute href=fonts.googleapis.com in my html

And it worked just fine afterwards.

This works for me. Thanks.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vivekiyer114 picture vivekiyer114  路  5Comments

adman020 picture adman020  路  5Comments

Messilimeng picture Messilimeng  路  4Comments

cmoulliard picture cmoulliard  路  3Comments

OussamaRomdhane picture OussamaRomdhane  路  4Comments