How to get non-english support when exporting to PDF? [duplicate]

萝らか妹 提交于 2020-02-28 06:16:40

问题


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


回答1:


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



来源:https://stackoverflow.com/questions/35607438/how-to-get-non-english-support-when-exporting-to-pdf

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!