问题描述
在我的 nodejs 应用程序中使用 html-pdf 包创建 pdf 文件时出现此错误
AssertionError [ERR_ASSERTION]: html-pdf: 无法在 html-pdf 中创建没有 html 字符串的 pdf
res.render('pdf/attend-report',{ data: attendData,date: `From: ${date(req.body.repFromDate || req.params.from)} To: ${date(req.body.repToDate || req.params.to)} - ${days} days(s)` },function(err,html) {
pdf.create(html,options).toFile('../public/pdf-html/attend-report.pdf',result) {
if (err) {
return console.log(err);
} else {
// console.log(res);
var datafile = fs.readFileSync('../public/pdf-html/attend-report.pdf');
res.header('content-type','application/pdf');
res.send(datafile);
}
});
})
如果我创建 html 链接“const html = fs.readFileSync('../views/pdf/attend-report.ejs','utf8');”我仍然找不到文件
修复此错误的任何帮助
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)