`

關於iReport 的轉化PDF 字體樣式失效的解決方法

阅读更多

iReport 進行PDF打印的時候如果發現字體樣式找不到,可以通過以下方法解決.

 

首先 : 請檢查你是否把 iTextAsian.jar,iTextAsianCmaps.jar 已經加入到了iReport 的classpath環境中.

 

如有請接著下一步.

 

其次: 查看每個欄位是否將 PDF Embedded 複選框勾選上,  PDF Foot Name : STSong-Light,  PDF  Encoding :  UniGB-UCS2-H (Chinese Simplified)

 

一般到了這個時候 pdf 中文都能打印出來,但是,你可能會發現,當選中 Bold 複選框,或者Italic 複選框 ,打印出來的PDF 樣式并沒有變化.何解???

在這需要感謝 Allen  他寫了一篇文章關於這個問題的解決方案,其博文地址為:http://jiamingwu.blogspot.com/2007/03/jasperreports.html

我用的iReport 版本是 2.0.5,此問題出現的位置為 1696 行

protected Font getFont(Map attributes)
	{
		JRFont jrFont = new JRBaseFont(attributes);

		Exception initialException = null;

		Color forecolor = (Color)attributes.get(TextAttribute.FOREGROUND);

		Font font = null;
		PdfFont pdfFont = null;
		FontKey key = new FontKey(jrFont.getFontName(), jrFont.isBold(), jrFont.isItalic());

		if (fontMap != null && fontMap.containsKey(key))
		{
			pdfFont = (PdfFont) fontMap.get(key);
		}
		else
		{
			pdfFont = new PdfFont(jrFont.getPdfFontName(), jrFont.getPdfEncoding(), jrFont.isPdfEmbedded());
		}

 將其修改為

pdfFont = new PdfFont(jrFont.getPdfFontName(), jrFont.getPdfEncoding(), jrFont.isPdfEmbedded(),jrFont.isBold(), jrFont.isItalic());

并將此文件編譯后的class文件添加至 jasperreports-2.0.5.jar中

 

 

 

  • 大小: 26.2 KB
1
1
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics