win8系统下JFreeChart1.0.1和iText集成时,中文字符出现乱码的处理办法
环境:JFreeChart 1.0.1、iText1.3 JFreeChart1.0.1中的Plot接口无提供setValueLabelFont的办法,没有法直接设置label的字体! 不过还好试了一下午总算弄出来了,具体代码如下:
Pdfwriter writer; |
记住别忘了添加iTextAisan.jar不然会报如下错误:下载地址:iTextAsian.jar下载(32&64位)
com.lowagie.text.DocumentException: Font 'sTsong-Light' with 'UniGB-UCs2-H' is not recognized.
at com.lowagie.text.pdf.BaseFont.createFont(Unknown source)
at com.lowagie.text.pdf.BaseFont.createFont(Unknown source)
at com.lowagie.text.pdf.AsianFontMapper.awtToPdf(Unknown source)
at com.lowagie.text.pdf.PdfGraphics2D.getCachedBaseFont(Unknown source)
at com.lowagie.text.pdf.PdfGraphics2D.setFont(Unknown source)
at com.lowagie.text.pdf.PdfGraphics2D.(Unknown source)
at com.lowagie.text.pdf.PdfContentByte.createGraphics(Unknown source)
at JFreeChartExample.convertToPdf(JFreeChartExample.Java:94)
at JFreeChartExample.main(JFreeChartExample.java:63)
com.lowagie.text.DocumentException: Font 'sTsong-Light' with 'UniGB-UCs2-H' is not recognized.
at com.lowagie.text.pdf.BaseFont.createFont(Unknown source)
at com.lowagie.text.pdf.BaseFont.createFont(Unknown source)
at com.lowagie.text.pdf.AsianFontMapper.awtToPdf(Unknown source)
at com.lowagie.text.pdf.PdfGraphics2D.getCachedBaseFont(Unknown source)
at com.lowagie.text.pdf.PdfGraphics2D.setFont(Unknown source)
at org.jfree.chart.title.TextTitle.arrangeRR(TextTitle.java:488)
at org.jfree.chart.title.TextTitle.arrange(TextTitle.java:450)
at org.jfree.chart.JFreeChart.drawTitle(JFreeChart.java:1125)
at org.jfree.chart.JFreeChart.draw(JFreeChart.java:1015)
at org.jfree.chart.JFreeChart.draw(JFreeChart.java:925)
at JFreeChartExample.convertToPdf(JFreeChartExample.java:97)
at JFreeChartExample.main(JFreeChartExample.java:63)
Exception in thread "main" java.lang.NullPointerException
at com.lowagie.text.pdf.Pdfwriter.addsimple(Unknown source)
at com.lowagie.text.pdf.PdfContentByte.setFontAndsize(Unknown source)
at com.lowagie.text.pdf.PdfGraphics2D.drawstring(Unknown source)
at org.jfree.text.TextUtilities.drawRotatedstring(TextUtilities.java:566)
at org.jfree.text.TextUtilities.drawRotatedstring(TextUtilities.java:600)
at org.jfree.text.TextFragment.draw(TextFragment.java:212)
at org.jfree.text.TextLine.draw(TextLine.java:174)
at org.jfree.text.TextBlock.draw(TextBlock.java:269)
at org.jfree.text.TextBlock.draw(TextBlock.java:231)
at org.jfree.chart.title.TextTitle.drawHorizontal(TextTitle.java:628)
at org.jfree.chart.title.TextTitle.draw(TextTitle.java:569)
at org.jfree.chart.JFreeChart.drawTitle(JFreeChart.java:1128)
at org.jfree.chart.JFreeChart.draw(JFreeChart.java:1015)
at org.jfree.chart.JFreeChart.draw(JFreeChart.java:925)
at JFreeChartExample.convertToPdf(JFreeChartExample.java:97)
at JFreeChartExample.main(JFreeChartExample.java:63)
相关文章
更多+-
05/31
-
05/02
-
02/18
-
04/17
-
06/26
手游排行榜
- 最新排行
- 最热排行
- 评分最高
-
动作冒险 大小:322.65 MB
-
角色扮演 大小:77.48 MB
-
动作冒险 大小:327.57 MB
-
角色扮演 大小:333 B
-
卡牌策略 大小:260.8 MB
-
模拟经营 大小:60.31 MB
-
模拟经营 大小:1.08 GB
-
角色扮演 大小:173 MB