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' }
});

转载于:https://www.cnblogs.com/yydown/p/11129314.html

你可能感兴趣的:(nodjs html 转 pdf)