Jasperreports display Chinese Characters

Source: Internet
Author: User

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.jarAndiTextAsianCmaps.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 setpdfFontNameAttribute with an appropriate font name existing in the Adobe Reader Font Pack (for example,
pdfFontName="STSong-Light"). SetpdfEncodingWith an appropriate encoding for that charset (I. e.
pdfEncoding="UniGB-UCS2-H"). SetisPdfEmbeddedTo
"false"
.

4. If you need to export your report to other formats, setfontNameAttribute with an appropriate True Type font name installed on your OS, or use
FONT_MAPExport 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.