Recently, when jasperreports is used, errors such as getformat or isassignablestream cannot be displayed in Chinese. ireportdesigner cannot display Chinese characters. Solve the following problems with the help of jasperreport:
Refer to http://jasperforge.org/uploads/publish/jasperreportswebsite/trunk/faq.html#FAQ25 last point
|
Why don't I see Asian characters (ckj) in the generated PDF file? |
|
|
|
In order to solve these problems, you'll have to do some initializing work. 1. When exporting reports to PDF format, jasperreports uses the itext library. If itext has to deal with CJK (Chinese Japanese Korean) fonts, it requires 2 extra libraries:
iTextAsian.jar AndiTextAsianCmaps.jar . Add these jars in the classpath of your application. 2. in order to be able to read the text generated with itext using CJK fonts, you will also need to download and install the special Acrobat Reader Asian Font Pack (if you don't, it's possible that your reader will still ask you to install it while opening A PDF file containing CJK fonts ). A good point to start this operation wocould be here. 3. Then, in your report setpdfFontName Attribute with an appropriate font name existing in the Adobe Reader Font Pack (for example,
pdfFontName="STSong-Light" ). SetpdfEncoding With an appropriate encoding for that charset (I. e.
pdfEncoding="UniGB-UCS2-H" ). SetisPdfEmbedded To "false" .
4. If you need to export your report to other formats, setfontName Attribute with an appropriate True Type font name installed on your OS, or use
FONT_MAP Export parameter. And that's all. |
|
|
|
Put the downloaded two itext jar packages under the project Lib. Http://download.csdn.net/detail/shanshanOK/2200343 this download link is available
Set the PDF Font in ireport. Note that the font name and encoding name are set to the default value when the built-in value is set to false.
Test successful