我正在尝试使用JSReport使用Mac上的Node JS生成PDF,我在JSReport站点(https://jsreport.net.net/learn/phantom-pdf#上找到了此资源phantomjs2(,但我不确定如何使用JSReport渲染快捷方式进行配置(如下面的代码中使用(
var http = require('http');
var jsreport = require('jsreport');
http.createServer(function (req, res) {
jsreport.render("<h1>Hello world</h1>").then(function(out) {
out.stream.pipe(res);
}).catch(function(e) {
res.end(e.message);
});
}).listen(1337, '127.0.0.1');
是的,您只需要在请求选项中指定完整的phantomjs版本。
jsreport.render({
template: {
content: '<h1>Hello world</h1>',
engine: 'none', // replace this with the engine that you are using
recipe: 'phantom-pdf',
phantom: {
phantomjsVersion: '2.1.1' // replace this with the exact version of phantom@2 that you have installed.
}
}
})