【发布时间】:2021-10-13 16:36:42
【问题描述】:
我正在尝试使用 npm html-pdf 将 HTML 文件转换为 PDF,但转换后的 PDF 不是 HTML(样式错误)。谁能告诉我我做错了什么?
var pdf = require('html-pdf');
var html = fs.readFileSync('./example.html', 'utf8');
pdf.create(html, options).toFile(folderName + '/' + fileName, function (err, res) { // if the file doesnt exist it will be created
if (err) return console.log(err);
console.log(res);
});
【问题讨论】:
-
您需要更具体地了解您的问题,并可能添加您的 example.html 的相关部分。既然如此,我们也帮不上什么忙。
-
如果使用
html-pdf命令行从example.html生成pdf,样式问题还存在吗?能发一下example.html的相关内容吗? -
从 HTML 生成的 PDF 文件看起来不像 HTML,文本太大,没有图像。