nodjs html 转 pdf

var fs = require('fs');
var pdf = require('html-pdf');//模块
//读取html 文件
var html = fs.readFileSync('./static.html', 'utf8');

//创建pdf
var options = { format: 'Letter' };
pdf.create(html, options).toFile('./export.pdf', function(err, res) {
if (err) return console.log(err);
console.log(res); // { filename: '/app/businesscard.pdf' }
});

猜你喜欢

转载自www.cnblogs.com/yydown/p/11129314.html
今日推荐