10
votes

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 :)

2
What happens using FoxIt Reader, Okular, or xpdf?Dave Jarvis
What is the character encoding set to for PDF generation within iReport? See also: fileformat.info/info/unicode/char/394/index.htmDave Jarvis
@Dave Jarvis: The Pdf Encoding was a deprecated parameter. In any case, it was CP1250 (Central European) in my text field and I tried it with CP1253 (Greek), Identity-H, Identity-V with no luck - probably nothing happened because of depracation... The link you have me is the character that has the problem - but what could I do with that ?Serafeim
Mind posting a simple JRXML example that reproduces the problem, without needing a database connection (i.e., make the query something like SELECT 1 FROM DUAL)? Use pastebin.com if necessary.Dave Jarvis

2 Answers

3
votes

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.

2
votes

In case anybody comes looking, I came across a similar problem, when generating PDF files from PHP and FPDF. In my case, the problem (and solution) was : When FPDF generates a font info file (font.php) via MakeFont, it creates a /Differences encoding sequence (as defined in PDF specs) which is then embedded in the PDF file. The /Differences sequence uses names from the "Adobe Glyph List", (http://partners.adobe.com/public/developer/en/opentype/glyphlist.txt) which is NOT the same as the Unicode glyph names... Looking at this list, I found the following entries :

Delta;2206
Deltagreek;0394  <-- this is the correct unicode point

the FPDF library was using the "Delta" name, which (I think) is meant to display the mathematical "delta" symbol.

By patching the generated .php font info file, and changing 'Delta' to 'Deltagreek', the problem was solved. You only need to do this once, per font info file.

While the above is valid for PDF and FPDP and PHP, I suspect that you are having the same problem with Jasper. You need to check how Jasper handles encodings, etc.

Hope this helps somebody :)