Webshot not working on Meteor in DigitalOcean Ubuntu 14.04

I use this code to generate pdf:

let fileUri = process.env.PWD + '/storage/orders-pdf/' + fileName; // Commence Webshot webshot(html_string, fileUri, options, function(error) { fs.readFile(fileUri, function (err, data) { if (err) { return console.log(err); } fs.unlinkSync(fileUri); fut.return(data); }); }); let pdfData = fut.wait(); 

But this causes the following error:

 { [Error: ENOENT, open '/opt/holi/storage/orders-pdf/Attributes.pdf'] errno: 34, code: 'ENOENT', path: '/opt/holi/storage/orders-pdf/Attributes.pdf' } 

Tried to use the npm package https://github.com/brenden/node-webshot Then the code works fine on the local host, but the server crashes and causes this error:

EDIT:

Even when taking a web snapshot without:

 fs.readFile(fileUri, function (err, data) { if (err) { return console.log(err); } fs.unlinkSync(fileUri); fut.return(data); }); 

File not created.

EDIT-2:

Webshot throws an error: [Error: PhantomJS exited with return value 2]

EDIT-3: Actual issue: https://github.com/brenden/node-webshot/issues/123

+6
source share
1 answer

I had a similar problem, and spent most of the day trying to figure out the problem. In the end, I added:

 "phantomPath": "/usr/bin/phantomjs" 

for my web snapshot settings object. I used the phantom path where mup installs phantomjs to configure your server.

0
source

All Articles