在生成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”解决了,虽然不知道为什么,但是猜测这个是字体组有关,因为雅黑有三种,常规、加粗、极细

 

相关文章:

  • 2022-12-23
  • 2021-04-07
  • 2021-12-21
  • 2022-12-23
  • 2022-12-23
  • 2021-12-05
  • 2022-12-23
  • 2021-05-30
猜你喜欢
  • 2022-12-23
  • 2021-08-28
  • 2022-03-05
  • 2021-06-25
  • 2022-12-23
  • 2021-09-29
  • 2022-12-23
相关资源
相似解决方案