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();
IText5.4.0 中文問題
修改
iTextAsian.jar 路徑 不好用,原因不知。
目前解決辦法是調用系統的字體。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.