在生成PDF使用windows自帶字體雅黑的時候不停的報“Font 'C:\WINDOWS\FONTS\msyh.ttc' with 'Identity-H' is not recognized”的錯誤
解決方案
將
static BaseFont yaHei = BaseFont.CreateFont("c://windows//fonts//msyh.ttc", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);//微軟雅黑
改為
static BaseFont yaHei = BaseFont.CreateFont("c://windows//fonts//msyh.ttc,0", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);//微軟雅黑
在字體路徑的后面加了一個“,0”解決了,雖然不知道為什么,但是猜測這個是字體組有關,因為雅黑有三種,常規、加粗、極細