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