原因:itextpdf和itext-asian包版本不匹配 可以使用如下版本 gradle: compile("com.itextpdf:itextpdf:5....
5.2.0 执行BaseFont bfChinesebfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2...-H", BaseFont.NOT_EMBEDDED);时报错: "Font 'STSong-Light' with 'UniGB-UCS2-H' is not recognized."
Could not load the following font : pdfFontName : STSong-Light pdfEncoding : UniGB-UCS2-H isPdfEmbedded...net.sf.jasperreports.engine.JRRuntimeException: Could not load the following font : pdfFontName : STSong-Light pdfEncoding : UniGB-UCS2
doc.addSubject("测试主题"); // itext 中文的处理 BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2
row - 2)); BaseFont bftemp = BaseFont.createFont("STSongStd-Light", "UniGB-UCS2...row - 2)); BaseFont bftemp = BaseFont.createFont("STSongStd-Light", "UniGB-UCS2...if(i==0){ BaseFont bftemp = BaseFont.createFont("STSongStd-Light", "UniGB-UCS2...row - 2)); BaseFont bftemp = BaseFont.createFont("STSongStd-Light", "UniGB-UCS2...row - 2)); BaseFont bftemp = BaseFont.createFont("STSongStd-Light", "UniGB-UCS2
FontFactory.TIMES_ROMAN, 12)); selector.addFont(FontFactory.getFont("STSongStd-Light", "UniGB-UCS2
/** * 新建一个字体,iText的方法 STSongStd-Light 是字体,在iTextAsian.jar 中以property为后缀 * UniGB-UCS2...代表竖版 */ BaseFont bfChinese = BaseFont.createFont("STSongStd-Light", "UniGB-UCS2
5.2.0 //创建一个支持中文的字体 BaseFont font = BaseFont.createFont("STSong-Light", "UniGB-UCS2
size, final int style) { try { BaseFont base = BaseFont.createFont("STSong-Light", "UniGB-UCS2...BaseFont.NOT_EMBEDDED); 2.方案2 引入iTextAsian.jar 包 BaseFont base = BaseFont.createFont("STSong-Light", "UniGB-UCS2...否则会报 com.lowagie.text.DocumentException: Font'STSong-Light' with 'UniGB-UCS2-H' is not recognized.
不同字体(这里定义为同一种字体:包含不同字号、不同style) BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2...static代码块优先于代码块执行 { try { hfFont = new Font(BaseFont.createFont("STSong-Light", "UniGB-UCS2...BaseFont bfChinese; try { bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2
2) { BaseFont bftemp = BaseFont.createFont("STSongStd-Light", "UniGB-UCS2...lists.size()-2) { BaseFont bftemp = BaseFont.createFont("STSongStd-Light", "UniGB-UCS2...(i==0){ BaseFont bftemp = BaseFont.createFont("STSongStd-Light", "UniGB-UCS2...if(i==0){ BaseFont bftemp = BaseFont.createFont("STSongStd-Light", "UniGB-UCS2
document.close(); 二、字体 新建一个字体,iText的方法 BaseFont bfChinese; bfChinese=BaseFont.createFont(“STSongStd-Light”,”UniGB-UCS2...STSongStd-Light 是字体,在jar 中以property为后缀 UniGB-UCS2-H 是编码,在jar 中以cmap为后缀 H 代表文字版式是横版,相应的 V 代表竖版 字体设置...不同字体(这里定义为同一种字体:包含不同字号、不同style) BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2...Font hfFont; { try { hfFont = new Font(BaseFont.createFont("STSong-Light", "UniGB-UCS2
BaseFont bfChinese; try { bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2...BaseFont bfChinese = null; try { bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2
// 字体 来源于 itext-asian jar包 BaseFont baseFont = BaseFont.createFont("STSong-Light", "UniGB-UCS2
form.getFields().keySet()); //设置宋体 BaseFont song =BaseFont.createFont("STSong-Light", "UniGB-UCS2
getPdfChineseFont() throws Exception { BaseFont bfChinese = BaseFont.createFont("STSongStd-Light", "UniGB-UCS2
FileOutputStream("hello.pdf")); //创建中文字体 BaseFont bfchinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2...//用于中文显示的Provider BaseFont bfChinese = BaseFont.createFont("STSongStd-Light", "UniGB-UCS2
filePath = outpath + name + ".pdf"; BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2
null; Font font2 = null; try { bf = BaseFont.createFont("STSong-Light", "UniGB-UCS2...null; Font font2 = null; try { bf = BaseFont.createFont("STSong-Light", "UniGB-UCS2
PdfFontFactory 创建字体 // 使用下面字体可以处理中文不显示的问题 return PdfFontFactory.createFont("STSongStd-Light", "UniGB-UCS2
领取专属 10元无门槛券
手把手带您无忧上云