Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 将jsreport与其他语言(非英语)一起使用_Javascript_Node.js_Pdf_Phantomjs_Jsreport - Fatal编程技术网

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

Javascript 将jsreport与其他语言(非英语)一起使用,javascript,node.js,pdf,phantomjs,jsreport,Javascript,Node.js,Pdf,Phantomjs,Jsreport,我需要生成PDF报告,但问题是我无法用波斯语呈现,简单示例: var http = require('http'); var jsreport = require('jsreport'); http.createServer(function(req, res) { jsreport.render({ template: { content: "<h2>سلام</h2>",// means "hello"

我需要生成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');
var http=require('http');
var jsreport=require('jsreport');
http.createServer(函数(req,res){
jsreport.render({
模板:{
内容:“سلام”//在波斯语中表示“你好”
引擎:“jsrender”,
配方:“幻影pdf”
}
})
.then(功能(输出){
出流管道(res);
}).catch(函数(e){
res.end(e.message);
});
}).听(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>