如何使用node.JS中的phantomJs将html内容呈现为pdf文件
我怎样才能生成一些PDF文件的HTML内容,并使用node.js中的phantom.js呈现文件和内容浏览器?
为什么不使用使用phantomJS的html-pdf npm模块?
代码示例
var fs = require('fs'); var pdf = require('html-pdf'); var html = fs.readFileSync('./test/businesscard.html', 'utf8'); var options = { format: 'Letter' }; pdf.create(html, options).toFile('./businesscard.pdf', function(err, res) { if (err) return console.log(err); console.log(res); // { filename: '/app/businesscard.pdf' } });