生成pdf设置中文字体出错 \simsun.ttc' with 'Identity-H' is not recognized或者type of font{0} is not recognized

错误写法:

PdfFontFactory.createFont("C:\\Windows\\Fonts\\simsun.ttc", PdfEncodings.IDENTITY_H,false);

BaseFont.CreateFont("C:\\Windows\\Fonts\\simsun.ttc", PdfEncodings.IDENTITY_H,false)

这两种写法是不对的,路径后面加上“,0”就好了;

正确写法:

PdfFontFactory.createFont("C:\\Windows\\Fonts\\simsun.ttc,0", PdfEncodings.IDENTITY_H,false);


BaseFont.CreateFont("C:\\Windows\\Fonts\\simsun.ttc,0", PdfEncodings.IDENTITY_H,false);

查询源码

生成pdf设置中文字体出错 \simsun.ttc' with 'Identity-H' is not recognized或者type of font{0} is not recognized_第1张图片

所以必须加逗号,后面加上0或者1,大于1会报错, 

你可能感兴趣的:(java基础,BugResolve)