Search code examples
javascriptnode.jscloud9-idefs

fs.readFileSync Error


I am trying to use the html-pdf node module to generate pdfs from html. I am currently running this using the cloud9 IDE.

My code is:

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

I get the following Error:

[Error: Fontconfig warning: ignoring C.UTF-8: not a valid language tag]

Does anyone know how i can resolve this issue?


Solution

  • This is due to a bug in fontconfig. You can see here

    Open your terminal and execute locale -a you will see list of fonts. Then select it like LC_ALL=C

    may it can help