NodeJS, можем ли мы использовать phantomJs 2 с ярлыком рендеринга jsreport
Я пытаюсь использовать jsreport для создания PDF с использованием узла js на Mac, я нашел этот ресурс на сайте jsreport ( https://jsreport.net/learn/phantom-pdf), но я не уверен, как именно настроить его с помощью ярлыка рендеринга 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');
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.
}
}
})