How to escape HTML special characters when rendering a PDF using EJS and WKHTMLTOPDF?

17 Views Asked by At

I have an express application that generates pdf documents. I use ejs as a template engine and then I use wkhtmltopdf.

ejs.renderFile(
    path.join(__dirname, 'pages', 'lettera.ejs'),
    {
      ...some variables
    },
    (err, str) => {
      wkhtmltopdf(str, { output: `${dir}/lettera.pdf` });
    },
  );

The problem is that accent letters don't get escaped. For example Venerdì becomes Venerdì. If I escape the variable manually with escape from lodash I get the full code: Venerdì => Venerdì.

How can I get the real accent letters?

0

There are 0 best solutions below