4

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

Community
  • 1
  • 1
Shay_t
  • 163
  • 1
  • 16
  • 4
    Consider to test you font directly in pdf http://stackoverflow.com/questions/35127956/how-can-i-test-if-my-font-is-rendered-correctly-in-pdf and check this [check list](http://stackoverflow.com/questions/34287186/jasper-report-hindi-pdf/34287509#34287509) – Petter Friberg Feb 25 '16 at 00:18
  • Let me know if you get stuck on something – Petter Friberg Feb 25 '16 at 00:24
  • @PetterFriberg hey, the example provided in the link was very helpful (the first link), i noticed that open sans dose not support hebrew, i decided to use the google noto (https://www.google.com/get/noto/). i need to support something like 5 languages dynamically, that means something like 6 fonts, should i load 6 'font extension' jars into the classpath, how dose that will work?. thank you – Shay_t Feb 25 '16 at 14:26
  • You need to change font dynamically?.... can't you find one font that supports them all? have you tried Dejavu sans? – Petter Friberg Feb 25 '16 at 14:33
  • Note I have suggested a duplicate of your current question (font did not support, same problem as in duplicate), no worry with duplicate this happens and gives more entry points to answer. If you feel its correct consider to accept.. For your new question I will try to give suggestion in comment if we don't find an agreement you can also consider to post a new question. – Petter Friberg Feb 25 '16 at 14:40
  • ok i will create a new question – Shay_t Feb 25 '16 at 15:24
  • http://stackoverflow.com/questions/35631571/jasper-report-load-multiple-font-extension – Shay_t Feb 25 '16 at 15:30
  • Hey @PetterFriberg "Dejavu sans" was working in the itext provided example, but not as a Font Extension, can you help ? – Shay_t Feb 25 '16 at 15:47
  • You bet!, and its already provided in the jasper-report distribution you do not need to do nothing really....just add the jasper-report-font....jar to classpath and set correct fontName in jrxml – Petter Friberg Feb 25 '16 at 15:48
  • I'm sorry I'm insisting but I take great care of keep SO clean, for me its more important then rep points, so please tell me why you do not feel its a duplicated. – Petter Friberg Feb 25 '16 at 15:50
  • ok got it :), working with "Dejavu sans" – Shay_t Feb 25 '16 at 15:51
  • thank you @PetterFriberg :-) – Shay_t Feb 25 '16 at 15:52
  • Your welcome, the duplicate why don't you answer great fellow... yes, no, don't care, don't bother me, what ever... : ) – Petter Friberg Feb 25 '16 at 15:56
  • can you write an answer, at least copy on of the comment, so i can mark it as correct ? – Shay_t Feb 25 '16 at 16:06
  • You see the answer would be same as in duplicated and since I'm happy without gaining rep points posting duplicated answers, I'm more happy if you accept the duplicated.. Note: its not negative to accept duplicated its positive... (if you check the duplicated you will see that he had a problem with the font ttf similar as yours, so solution is same... switch font), If you like one of my answers you can always up vote those : ) – Petter Friberg Feb 25 '16 at 16:25
  • Its all about creating a great place on SO, where its easy to find stuff... – Petter Friberg Feb 25 '16 at 16:26

1 Answers1

3

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

Community
  • 1
  • 1
Petter Friberg
  • 21,252
  • 9
  • 60
  • 109