Jasper reports with PDF and Unicode (greek) characters

Serafeim picture Serafeim · Apr 19, 2011 · Viewed 8.4k times · Source

I have a very strange problem: I am trying to export a Jasper report containing Unicode characters (greek) as a PDF. My problem is that a specific greek character (the character delta) is printed in a different font face from the one I am using (Arial) !

The following image is copied from the exported pdf:

i dont like this

While the following image is the same text from MS Word using the same font:

this is much better

As you can see, the third letter (delta) is different from the others. This happens ONLY for this letter, for all font sizes. I also tried to change the font to garamond, but still got the same problem with exactly the same letter !

Finally, I should add that the internal preview from iReport is ok, also ok is the export to other formats like docx or html ...

Update 20/04/11: I also tried to open the pdf with Foxit reader portable - but had exactly the same behaviour as with Adobe Acrobat Reader.

Update 28/04/11: I have created a snippet in pastebin that generates the problem when exported to pdf. One warning - you have to "install" the font you will use (Arial in my case) through "Options - Fonts" of iReport or else you won't be able to see anything at all in the pdf.

Update 05/03/13 SOLUTION: Well since there are people (probably from Greece) that still have the same problem and view this question, I'd like to make another update: I started using again Jasper reports, however now I am using a newer version of Jasper (Jasper 5) and iReport (iReport 5). Everything is working ok now -- no problematic deltas in PDFs :) So just try upgrading your iReport and Jasper libraries if you experience the same problem !!

Update 05/04/13 Final Comments: After two years, I was able to work again on the system with the problematic greek character (delta) and was able to draw some final conclusions about the problem: So, first I upgraded the version of Jasper we were using to 5.x and still experienced the problem ! The problem was fixed only when I changed the included font extension (.jar) with a new one that I created (exported) from iReport 5.x. So, the problem was that when exporting the font extension, iReport 3.x (which was used to export the old extension) didn't export the greek character delta correctly, while iReport 5.x exports it fine. So my suggestion is still true: Any people having this problem upgrade your Jasper version to 5.x but also re-export your font extensions through iReprot 5.x. I really hope I won't do any more updates to this :)

Answer

mdahlman picture mdahlman · Dec 21, 2011

Font extensions. The answer is font extensions. (The answer is always font extensions.)

When I run your report I get a different result: I don't see any of the Greek characters. I can solve it by changing the font. Or I can solve it by adding Arial as a Font Extension. (Or I could probably solve it by putting Arial into the classpath somewhere... but don't do that. It's asking for trouble.) I wrote about font extensions a while back. They were created to solve this type of issue. That's what you should use.

Because the report behaved differently for me, I'm only mostly sure that this is the answer. Let us know.