当我运行时,我收到错误
GET /pdfreport - - ms - -
WARRNING! '$data.ObjectID' not supported as computed Key!
WARRNING! '$data.ObjectID' not supported as computed Key!
WARRNING! '$data.ObjectID' not supported as computed Key!
WARRNING! '$data.ObjectID' not supported as computed Key!
WARRNING! '$data.ObjectID' not supported as computed Key!
Recipe phantom-pdf was not found.
GET /pdfreport - - ms - -
{ [Error: ENOENT, unlink '/var/folders/r0/l6_3z9g55x95s7dp34yt3scw0000gn/T/xcrun_db']
errno: 34,
code: 'ENOENT',
path: '/var/folders/r0/l6_3z9g55x95s7dp34yt3scw0000gn/T/xcrun_db' }
我的节点快速路由设置如下:
app.route('/pdfreport')
.get(function (req, res) {
var jsreport = require('jsreport');
jsreport.bootstrapper(jsreport.renderDefaults).start().then(function(conf) {
conf.reporter.render({
template: {
content: "<h1>Hello world</h1>",
phantom: {
header: "<p>some header</p>",
orientation: "portrait",
width: "300px"
}
}
}).then(function(out) {
out.result.pipe(res);
}).fail(function(e) {
console.log(e);
});
});
});
我不确定如何解决此错误。我在网上看过Recipe phantom-pdf没找到。
答案 0 :(得分:3)
这是在最新的0.2.3版本中修复的,只需执行npm install jsreport
即可。
一些提示:
您应该启用记录器来调查这些问题:
jsreport.renderDefaults.logger.providerName = "console";
如果没有任何理由,您不应为每个请求引导jsreport。您可以考虑使用为您缓存单个实例的渲染快捷方式:
app.route('/pdfreport')
.get(function (req, res) {
require('jsreport').render({
template: {
content: "<h1>Hello world</h1>",
phantom: {
header: "<p>some header</p>",
orientation: "portrait",
width: "300px"
}
}
}).then(function(out) {
out.result.pipe(res);
}).fail(function(e) {
console.log(e);
});
});
文档为here