Open ganesh143143 opened 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?
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
Based on the error require('phantomjs-prebuilt').path
is not producing valid path.
Try to debug it.
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)