【发布时间】:2016-12-12 12:57:48
【问题描述】:
我需要阅读 pdf 文件,我使用 pdf-text-extract。它在我的本地主机上完美运行。但是当我尝试在服务器上运行程序时,我得到了以下错误
spawn called
{ '0': 'pdftotext',
'1':
[ '-layout',
'-enc',
'UTF-8',
'/tmp/the_file_name.pdf',
'-' ],
'2': { encoding: 'UTF-8', layout: 'layout', splitPages: true } }
events.js:72
throw er; // Unhandled 'error' event
Error: spawn ENOENT
at errnoException (child_process.js:1011:11)
at Process.ChildProcess._handle.onexit (child_process.js:802:34)
这是我如何使用pdf-text-extract
var extract = require('pdf-text-extract');
.....
.then (function () {
console.log(fs.readdirSync('/tmp'));
var extractAsync = Promise.promisify(extract);
return extractAsync(filePath);
})
.catch (function (err) {
console.log(err);
});
如你所见,我添加了catch,但是为什么错误是Unhandled 'error' 事件。
我还使用fs.readdirSync 检查了该文件是否存在。是什么导致了错误,我该如何解决?
【问题讨论】: