javascript - fs.readFileSync 错误

标签 javascript node.js cloud9-ide fs

我正在尝试使用 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/

相关文章:

javascript - 仅显示 html 中第一个逗号之前的内容

node.js - 谷歌云功能 : support for Google Cloud KMS

javascript - 如何将数组中每个元素的结果推送到javascript nodejs中的全局变量?

javascript - 超链接不适用于 Angular-fullstack yo 生成器

javascript - Cloud9 中的 Mocha 测试出现 "undeclared variable"警告

javascript - 无法在node.js上使用 Nightmare API返回document.querySelector

node.js - 在cloud9ide中上传图片?

javascript - 处理订单队列 (Redis) 的最佳选择是什么?

javascript - 显示内容 Jquery

javascript - 如何将 jade-agents (java) 和 babylon.js (html/javascript) - Servlet 连接到 html?