Error: html-pdf: PDF generation timeout. Phantom.js script did not exit.
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.
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.
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
This worked for me! Thanks a lot.
there is some problem in this library when loading the images, even being in the aws s3 the pdf takes a very long time to load. When images are removed from html the pdf loads very fast.
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.
Bro this solved mine too. I changed the image source and haven't changed it on the html template. So the "html-pdf" module keep waiting the image, to render, as it don't exist, so it will never render, ocorruring in a time out error.
Same issue here, would try extending the timeout, image is inside the server and no fonts.googleapis
same issue image tag was loading huge data.. i removed and it worked