如何在导出为PDF时获得非英语支持? [英] How to get non-english support when exporting to PDF?

查看:131
本文介绍了如何在导出为PDF时获得非英语支持?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用JasperReport 6.2版本

我想将报表导出为PDF,但是我的报表不支持与英语不同的语言(其他语言字段显示为空白),

这是我生成报表的代码

  JsonDataSource ds = new JsonDataSource(JRLoader.getInputStream(jsonFile)); 
JasperReport jasperReport =(JasperReport)JRLoader.loadObject(jasperFile);
parameters.put(JRParameter.REPORT_FILE_RESOLVER,new SimpleFileResolver(new File(reportDirPath)));
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport,parameters,ds);
JasperExportManager.exportReportToPdfFile(jasperPrint,outputFilePath);

我使用本教程创建了一个字体扩展:



我导出到jar文件并添加到我的项目类路径中,但所有不是英文的字段都是空白的



这个链接非常有帮助,它帮助我认识到,如果我的字体首先支持渴望的语言

解决方案

这里的问题是字体(ttf)不支持语言(使用我怎样才能测试,如果我的字体在PDF中正确呈现?))所以问题类似如何在输出为PDF格式时正确显示印地文?



解决方案:找到支持语言的字体并使用字体扩展名。



关于如何在语言之间切换字体,后续问题:贾斯珀报告,加载多个字体扩展名



//社区wiki,因为我喜欢重复,但在低流量的标签中很困难$ / b>

I am using JasperReport version 6.2

And I want to export report to PDF, but my report will not support languages different then English (other languages fields appear as blank),

This is my code for generating the report

JsonDataSource ds = new JsonDataSource(JRLoader.getInputStream(jsonFile));
JasperReport jasperReport = (JasperReport)  JRLoader.loadObject(jasperFile);
parameters.put(JRParameter.REPORT_FILE_RESOLVER, new SimpleFileResolver(new File(reportDirPath)));
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, ds);
JasperExportManager.exportReportToPdfFile(jasperPrint, outputFilePath);

I created a Font Extension using this tutorial: "http://community.jaspersoft.com/wiki/custom-font-font-extension"

I export to jar file and add to my project class path, but all fields that are not in English are Still blank

peter comment with this link was very helpful, it help me realize if my font is supporting the desire language in the first place

解决方案

The problem here was that font (ttf) did not support the language (tested using this How can I test if my font is rendered correctly in pdf?) so problem similar to How can I render hindi correctly when exporting to pdf?)

Solution: Find a font that support the language(s) and use font-extension.

For how to switch font between languages see this follow up question: Jasper report, load multiple Font Extension

//Community wiki since I would preferred duplicated but difficult in low-traffic tag

这篇关于如何在导出为PDF时获得非英语支持?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆