Elyas74
Elyas74

Reputation: 548

use jsreport with other languages (not in English)

I need to generate PDF reports ,but the problem is I can't render with Persian language ,simple example :

var http = require('http');
var jsreport = require('jsreport');

http.createServer(function(req, res) {
    jsreport.render({
            template: {
                content: "<h2>سلام</h2>",// means "hello" in persian
                engine: 'jsrender',
                recipe: 'phantom-pdf'
            }
        })
        .then(function(out) {
            out.stream.pipe(res);
        }).catch(function(e) {
            res.end(e.message);
        });

}).listen(3031, '127.0.0.1');

Generated PDF contain something wrong and unreadable, any idea? Thanks for any advise.

Upvotes: 1

Views: 442

Answers (1)

Jan Blaha
Jan Blaha

Reputation: 3095

From the documentation

To be able to print correct national characters into pdf you need to set utf-8 charset in your html first.

<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body>
     سلام
  </body>
</html>

Playground example here

Upvotes: 1

Related Questions