将JSreport与其他语言(非英语)一起使用

use jsreport with other languages (not in English)

本文关键字:英语 一起 JSreport 其他 语言      更新时间:2023-09-26

我需要生成PDF报告,但问题是我不能用波斯语渲染,简单的例子:

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

生成的PDF包含错误和不可读的内容,知道吗?感谢您的任何建议。

来自文档

为了能够将正确的国家字符打印成pdf,您需要 首先在 HTML 中设置 UTF-8 字符集。

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

游乐场示例在这里