我正在尝试使用 html-pdf Node 模块从 html 生成 pdf。我目前正在使用 cloud9 IDE 运行它。
我的代码是:
var fs = require("fs");
var pdf = require('html-pdf');
var html = fs.readFileSync('./test.html', {encoding: 'utf8'});
var options = { format: 'Letter' };
app.post('/pdf',function(req, res) {
pdf.create(html, options).toFile('./businesscard.pdf', function(err, res) {
if (err) return console.log(err);
console.log(res); // { filename: '/app/businesscard.pdf' }
});
});
我收到以下错误:
[Error: Fontconfig warning: ignoring C.UTF-8: not a valid language tag]
有谁知道我该如何解决这个问题?
最佳答案
This is due to a bug in
fontconfig
. You can see here
打开终端并执行locale -a
,您将看到字体
列表。然后选择它,例如 LC_ALL=C
希望能帮到你
关于javascript - fs.readFileSync 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39892184/