pofider / phantom-html-to-pdf

Highly scalable html to pdf conversion using phantom workers
MIT License
159 stars 33 forks source link

"file" argument must be a non-empty string #104

Open ganesh143143 opened 5 years ago

ganesh143143 commented 5 years ago

error: Uncaught exception occured, TypeError: "file" argument must be a non-empty string TypeError: "file" argument must be a non-empty string at normalizeSpawnArguments (child_process.js:380:11) at exports.spawn (child_process.js:493:38) at Object.exports.execFile (child_process.js:209:15) at D:\Projects\EXA\emd_development\node_modules\phantom-html-to-pdf\lib\dedicatedProcessStrategy.js:47:34 at D:\Projects\EXA\emd_development\node_modules\graceful-fs\graceful-fs.js:43:10 at FSReqWrap.oncomplete (fs.js:149:20)

pofider commented 5 years ago

Please take a look at what is sent here. The first argument should be a path to the phantomjs. Is it properly installed?

ganesh143143 commented 5 years ago

I used like this

const htmlPDF = require('phantom-html-to-pdf')({ 'numberOfWorkers': 2, 'tmpDir': TEMP_DIR, 'strategy': "dedicated-process", 'phantomPath': require('phantomjs-prebuilt').path });

As per node https://www.npmjs.com/package/phantomjs is renamed to phantom-prebuilt . So i used the phantom prebuilt.

htmlPDF({ html}, ( error, pdf ) => { if ( error ) { reject({'message': Unable to create file ${fileName}, error}); } else { const { path: tmpPath } = pdf.stream;

   const fileStream = fs.createWriteStream(fileName);
   pdf.stream.pipe(fileStream);

}})

Please help me what is wrong in my code

pofider commented 5 years ago

Based on the error require('phantomjs-prebuilt').path is not producing valid path. Try to debug it.