com.itextpdf.text.DocumentException: Font 'STSong-Light' with 'UniGB-UCS2-H' is not recognized.
at com.itextpdf.text.pdf.BaseFont.createFont(BaseFont.java:699)
at com.itextpdf.text.pdf.BaseFont.createFont(BaseFont.java:606)
at com.itextpdf.text.pdf.BaseFont.createFont(BaseFont.java:441)
at com.happy.pdf.WritePDF.chinesePDF(WritePDF.java:81)
at com.happy.pdf.WritePDF.main(WritePDF.java:34)
Exception in thread "main" java.lang.RuntimeException: The document is not open.
at com.itextpdf.text.pdf.PdfWriter.getDirectContent(PdfWriter.java:713)
at com.itextpdf.text.pdf.PdfDocument.isPageEmpty(PdfDocument.java:2182)
at com.itextpdf.text.pdf.PdfDocument.newPage(PdfDocument.java:820)
at com.itextpdf.text.pdf.PdfDocument.close(PdfDocument.java:770)
at com.itextpdf.text.Document.close(Document.java:420)
at com.happy.pdf.WritePDF.chinesePDF(WritePDF.java:97)
at com.happy.pdf.WritePDF.main(WritePDF.java:34)
修改:iTextAsian.jar 的包名,修改为:com.itextpdf.text.pdf.fonts
分享到:
相关推荐
标题 "输出中文Font 'STSongStd-Light' with 'UniGB-UCS2-H' is not recognized" 提供了一个IT问题,主要涉及到在处理中文字符时遇到的字体识别问题。iText是一个流行的Java库,用于创建和修改PDF文档。在这个问题中...
BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); Font fontChinese = new Font(bfChinese, 12, Font.NORMAL); document.add(new Paragraph(new Chunk("你的...
BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.EMBEDDED); Font chineseFont = new Font(bfChinese, 12, Font.NORMAL); // 在Paragraph中使用新字体 document.add(new ...
BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); Font chineseFont = new Font(bfChinese, 12, Font.NORMAL); document.add(new Paragraph("你好,iText!", ...
BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); Font font = new Font(bfChinese, 48, Font.BOLD, new GrayColor(0.5f)); for (int page = 1; page ...
BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); Font chineseFont = new Font(bfChinese, 12, Font.NORMAL, Color.BLACK); document.add(new Paragraph(...
AsianFontMapper mapper = new AsianFontMapper("STSong-Light", "UniGB-UCS2-H"); ``` 这里,"STSong-Light"是中文宋体的名称,"UniGB-UCS2-H"代表使用Unicode的大字体格式。 2. **引入iTextAsian.jar**: 要...