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 中文问题
最新推荐文章于 2021-08-03 21:34:36 发布
修改
iTextAsian.jar 路径 不好用,原因不知。
目前解决办法是调用系统的字体。