Node-html-pdf: Chinese characters shows up as boxes in the generated pdf

Created on 10 Jun 2015  路  6Comments  路  Source: marcbachmann/node-html-pdf

Hi,

I am using this module to transform html to pdf on the fly in my website. What i observed is whenever there are Chinese characters in my html, it transforms to boxes in pdf. Is this you are aware of?

Here is the snippet

var options = {format: 'Letter'};
options.border = {
  "top": "30px",
  "right": "30px",
  "bottom": "30px",
  "left": "30px"
};

pdf.create(html, options).toStream(function (err, stream) {
          //TODO:Handle err
          res.setHeader('Content-Type', 'application/pdf');
          res.setHeader('Content-disposition', 'attachment; filename="'+ 'Document - '+result.docId + '.pdf"');
          stream.pipe(res);
});

Most helpful comment

@sripaulgit Which fonts on Ubuntu?

All 6 comments

This either has something to do with some missing fonts or with the unicode
problem that phantomjs has.

This problem occurs when the html doesn't contain a charset and falls back
to iso8859-1. This is fixed in phantomjs 2 and thus will be fixed in here
soon.

I knew of the problem where emojis aren't rendered. Thanks for reporting.

Maybe I should write some FAQs 馃榾

I installed the fonts and it worked :smile: Thanks!

hehe :smile: Good to know.

@sripaulgit Which fonts on Ubuntu?

@sripaulgit Which fonts on CentOS?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

adman020 picture adman020  路  5Comments

Messilimeng picture Messilimeng  路  4Comments

RodolfoSilva picture RodolfoSilva  路  3Comments

B-StS picture B-StS  路  5Comments

wobsoriano picture wobsoriano  路  3Comments