使用wkhtmltopdf时遇到问题,我刚刚安装了64位版本和nodejs依赖项,但是我收到错误:
我的代码:
var wkhtmltopdf = require('wkhtmltopdf');
wkhtmltopdf('http://google.com/', { pageSize: 'letter' }).pipe(fs.createWriteStream('/out.pdf'));

我的错误:
events.js:72
throw er; // Unhandled 'error' event
^
Error: spawn ENOENT
at errnoException (child_process.js:1001:11)
at Process.ChildProcess._handle.onexit (child_process.js:792:34)
npm ERR! GestionDettes@1.2.0 start: `node ./bin/www`
npm ERR! Exit status 8
npm ERR!
npm ERR! Failed at the *******@1.2.0 start script.
npm ERR! This is most likely a problem with the GestionDettes package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node ./bin/www
npm ERR! You can get their info via:
npm ERR! npm owner ls GestionDettes
npm ERR! There is likely additional logging output above.
npm ERR! System Windows_NT 6.2.9200
npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
npm ERR! cwd C:\xampp\htdocs\*******
npm ERR! node -v v0.10.33
npm ERR! npm -v 1.4.28
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! C:\xampp\htdocs\********\npm-debug.log
npm ERR! not ok code 0

答案 0 :(得分:3)
确保已安装wkhtmltopdf命令行工具。您可以从以下网址下载:http://wkhtmltopdf.org/downloads.html
然后确保PATH上有bin
文件夹。 C:\Program Files\wkhtmltopdf\bin
是默认安装路径。验证它是否适合您的机器。
答案 1 :(得分:0)
由于我们在Docker容器中使用了Js Report,因此在Windows 10系统中渲染pdf时遇到Spawn错误wkhtmltopdf.exe执行的问题。
我们如何解决:- 在包json中,我们明确添加了“ wkhtmltopdf-installer”包,因此将wkhtmltopdf.exe更新为64位。
{“ wkhtmltopdf-installer”:“〜0.3.2”}