IText5.4.0 中文問題

修改  iTextAsian.jar 路徑 不好用,原因不知。
目前解決辦法是調用系統的字體。

Document document = new Document();// 配置pdf的輸出流 
try {

PdfWriter
.getInstance(document, new FileOutputStream("C://xxx.pdf")); //  打開document 
document.open();//  添加數據入pdf 
BaseFont baseFontChinese = BaseFont.createFont("C:/WINDOWS/Fonts/SIMYOU.TTF", BaseFont.IDENTITY_H,BaseFont.NOT_EMBEDDED);
Font fontChinese = new Font(baseFontChinese, 12, Font.NORMAL);
Paragraph graph = new Paragraph("測試中文", fontChinese);
document.add(graph);

} catch (DocumentException de) {
System.err.println(de.getMessage());
} catch (IOException ioe) {
System.err.println(ioe.getMessage());
} finally {

}
//  關閉document 
document.close();



發佈了70 篇原創文章 · 獲贊 2 · 訪問量 6萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章