R-J*_*R-J 6 node.js meteor digital-ocean ubuntu-14.04
我正在使用此代码生成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();
Run Code Online (Sandbox Code Playgroud)
但它会引发以下错误:
{ [Error: ENOENT, open '/opt/holi/storage/orders-pdf/Attributes.pdf']
errno: 34,
code: 'ENOENT',
path: '/opt/holi/storage/orders-pdf/Attributes.pdf' }
Run Code Online (Sandbox Code Playgroud)
尝试使用npm包https://github.com/brenden/node-webshot 然后代码在localhost上完美运行,但在服务器上失败并抛出此错误:
编辑:
即使在没有运行webshot的情况下:
fs.readFile(fileUri, function (err, data) {
if (err) {
return console.log(err);
}
fs.unlinkSync(fileUri);
fut.return(data);
});
Run Code Online (Sandbox Code Playgroud)
该文件未创建..
EDIT 2:
Webshot抛出一个错误: [Error: PhantomJS exited with return value 2]
我也遇到了类似的问题,花了一整天的时间试图解决这个问题。我最终添加:
"phantomPath": "/usr/bin/phantomjs"
Run Code Online (Sandbox Code Playgroud)
到我的网络快照选项对象。我使用的幻像路径是 mup 在您的服务器设置上安装 phantomjs 的位置。
| 归档时间: |
|
| 查看次数: |
370 次 |
| 最近记录: |