Jasperreports 显示中文

最近使用Jasperreports 中文总是无法显示 getFormat错误或 isAssignableStream之类的错误,结合iReportDesigner 依然出现无法显示中文。在jasperreport常见问题帮助下解决:


 参考http://jasperforge.org/uploads/publish/jasperreportswebsite/trunk/faq.html#FAQ25 最后一点


 

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 and iTextAsianCmaps.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 would be here.

3. Then, in your report set the pdfFontName attribute with an appropriate font name existing in the Adobe Reader font pack (for example, pdfFontName="STSong-Light"). Set the pdfEncoding with an appropriate encoding for that charset (i.e. pdfEncoding="UniGB-UCS2-H"). Set isPdfEmbedded to "false".

4. If you need to export your report to other formats, set the fontName attribute with an appropriate true type font name installed on your OS, or use the FONT_MAP export parameter.
And that's all.
 
  

将下载好的2个iText的jar包放在工程lib下即可。http://download.csdn.net/detail/shanshanOK/2200343 此下载链接可用

在iReport中设置pdf字体即可,注意第三点,设置字体名称,编码名称,内置设为false即为默认值,不要选择打钩。
测试成功


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值