ireport导出中文pdf

准备:

报表开发工具:ireport 5.6.0

报表框架: jasperreport5.6.0


1、设置pdf fontname、isembedded、pdfencoding

pdf fontname=STsong-light

isembedded=true

pdfencoding=Unigb-UCS2-H simplified

注意字体必须是STSong-light,否则会出现异常,异常信息如下

Error exporting print... Could not load the following font :  pdfFontName   : Helvetica pdfEncoding   : UniGB-UCS2-H isPdfEmbedded : true 
net.sf.jasperreports.engine.JRRuntimeException: Could not load the following font :  pdfFontName   : Helvetica pdfEncoding   : UniGB-UCS2-H isPdfEmbedded : true      at net.sf.jasperreports.engine.export.JRPdfExporter.getFont(JRPdfExporter.java:2117)      at net.sf.jasperreports.engine.export.JRPdfExporter.getChunk(JRPdfExporter.java:1906)      at net.sf.jasperreports.engine.export.JRPdfExporter.getPhrase(JRPdfExporter.java:1875)      at net.sf.jasperreports.engine.export.SimplePdfTextRenderer.getPhrase(SimplePdfTextRenderer.java:89)      at net.sf.jasperreports.engine.export.SimplePdfTextRenderer.render(SimplePdfTextRenderer.java:100)      at net.sf.jasperreports.engine.export.JRPdfExporter.exportText(JRPdfExporter.java:2238)      at net.sf.jasperreports.engine.export.JRPdfExporter.exportElements(JRPdfExporter.java:950)      at net.sf.jasperreports.engine.export.JRPdfExporter.exportPage(JRPdfExporter.java:909)      at net.sf.jasperreports.engine.export.JRPdfExporter.exportReportToStream(JRPdfExporter.java:786)      at net.sf.jasperreports.engine.export.JRPdfExporter.exportReport(JRPdfExporter.java:513)      at com.jaspersoft.ireport.designer.compiler.IReportCompiler.run(IReportCompiler.java:1174)      at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:572)      at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:997)  Caused by: ExceptionConverter: java.io.UnsupportedEncodingException: UniGB-UCS2-H


设置效果图

ireport导出中文pdf_第1张图片



2、设置ireport的classpath添加字体包,itextasian-1.5.2.jar,itextasianCmaps.jar,重启iReport


itextasian.jar下载

itextasianCmaps.jar下载

ireport导出中文pdf_第2张图片



3、效果

ireport导出中文pdf_第3张图片


你可能感兴趣的:(jasperReport)