Thursday, January 17, 2008

Ireport and non ISO-8859-1 characters

If we want to produce a report using Ireport in other language with a different character set than the standard English in PDF(Vietnamese,Chinese,Japanese, etc.) , we need to use a font that supports UTF-8 encoding (for example, Arial) if we want to make sure that the characters prints out correctly.

Let say that we need to set the PDF font to Arial. It won't be in the dropdown list if we don't copy it to Ireport's lib folder. Once done, right click on the field that we want to be displayed in the other character set and view the properties. Go to the Font tab and select Arial from the dropdown list of the PDF Font Name field. Put a tick on the PDF Embedded check box and select :y-H (Unicode with horizontal writing). Save and compile the file.

Lastly, be sure to put the font file in your application's classpath or the report will be blank as it can't find the font to embed to the PDF file.