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
source share