ireport and Jasperreport Chinese support

Source: Internet
Author: User

1 Operating Environment
1.1 Jasperreport
JasperReports is the core content of ireport. It is a powerful Open-source report generation tool that can output content to screens, printers, or generate PDFs, HTML, XLS, CSV, and XML files. It is written entirely in Java and can be used to generate dynamic report content in a variety of Java applications, including EE or Web applications. The JasperReports organization accesses data in the relational database through JDBC based on the report design defined in an XML file. You must first compile the report design into a Jasper file before populating the report data.
Download Address: http://jasperreports.sourceforge.net/
1.2 IReport
ireport is an excellent visual development tool for making Jasperreport XML files, which makes it easy to design report templates. Currently the highest version is ireport
Download Address: http://ireport.sourceforge.net
1.3 IText 1.3.1
Itext is an open source Java class Library that is used to generate PDF files.
Download Address: http://itext.sourceforge.net
1.4 Itextasian.jar
If you want to display Asian characters such as Chinese in the generated PDF file, you must also download the Itext Asian character pack.
Download Address: Http://itextdocs.lowagie.com/downloads/iTextAsian.jar
The above three packages must be added to the application's build path or added to the classpath (emphasis, the tool has a classpath option to add your jar ******************) if the Web application is placed in the corresponding web-inf/lib/.
2 Setting up Chinese support
In order to be able to display Chinese in the report, it is not enough to add four packages (because the above three packages only provide support for report generation and Chinese display), you must set the related properties for each display object on the report, and the property settings are as follows:
Font name: XXFarEastFont-Arial (Chinese font)
PDF Font Name:stsong-light
PDF encoding:unigb-ucs2-h (Chinese siplified)
PDF embeded:√
As shown in the following illustration (display the object's property settings):

Note: The settings for these three items must ensure that the Itextasian.jar Asian language pack is already included in the project, otherwise there will be a compilation error.
If the reader finds it troublesome to set up each object, you can set it up in the ireport "Format"  "Fonts" menu and set it as the default font for the report.


Reason: report display object's PDF Font Property set incorrectly
Workaround: The report object's settings for font properties are as follows:
Font name: XXFarEastFont-Arial (Chinese font)
PDF Font Name:stsong-light
PDF encoding:unigb-ucs2-h (Chinese siplified)
PDF embeded:√


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.