Search code examples
pdffontsjasper-reports

How to get non-english support when exporting to PDF?


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"

enter image description here

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


Solution

  • 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