views:

1529

answers:

4

Hi. I am trying to generate or export to PDF a jasper report but I can't displaynihongo or japanese characters. How do I fix this... :(

+1  A: 

You have to embed UTF-8 fonts in the PDF.

  1. get the utf-8 fonts and place them on your classpath
  2. for older jasper-reports version use a custom style and apply it to all texts
  3. before printing, call style.setPdfFontName("/com/package/fonts/times.ttf");

For newer versions the PdfFontName is deprecated instead of another way of doing this, but I can't find it now - look it up yourself.

Another workaround might be found here

Bozho
+2  A: 

Make a file "jasperreports.properties", put it in the class path and set the PDF encoding.

net.sf.jasperreports.default.pdf.encoding=Cp1250

Or make base style in a report, set what you need, and all other styles derive from this style, i.e. they have an attribute style="base".

xmedeko
A: 

You can also set "net.sf.jasperreports.default.pdf.encoding" in code like this:

JRProperties.setProperty("net.sf.jasperreports.default.pdf.encoding", "Cp1250");
zigomir