准备:
报表开发工具: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
2、英文数字设置pdf fontname、isembedded、pdfencoding
pdf fontname=default
isembedded=true
pdfencoding=CP1252
注意字体不能设置成STSong-light,否则会出现异常