TCPDF 添加新字体 教程

TCPDF是一个PHP库,用于即时生成PDF文档。该库可能包含使用不同许可证发布的第三方字体文件。

github: https://github.com/tecnickcom/TCPDF

 

1、将字体复制到TCPDF\tools 目录下

 

2、打开CMD窗口定位到 vendor\tecnickcom\TCPDF\tools 目录 执行下面的命令:

我们以微软雅黑字体为例:

 php ./tcpdf_addfont.php -b -t TrueTypeUnicode -f 97 -i msyh.ttf

 

如果成功CMD会出现下面的代码:

>>> Converting fonts for TCPDF:
*** Output dir set to C:\phpStudy\PHPTutorial\WWW\chuanqi\vendor\tcpdf/fonts/
+++ OK   : C:\phpStudy\PHPTutorial\WWW\chuanqi\vendor\tcpdf\tools\msyh.ttf added
 as msyh
>>> Process successfully completed!

这时微软雅黑字体就转换完成并复制到TCPDF\fonts目录下了。

 

3、直接设置字体即可!

 

tcpdf_addfont.php代码:

 $tcpdf = new \TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
 $tcpdf->SetFont('msyh', '', 10, '', true);

 

注意:如果php不是内部命令,请将php目录加入环境遍量。

    A+
发布日期:2020年12月29日 12:23:55  所属分类:PHP
最后更新时间:2020-12-29 12:23:55
头像
  • ¥ 99.0元
  • 市场价:129.0元
  • ¥ 199.0元
  • 市场价:399.0元
  • ¥ 298.0元
  • 市场价:498.0元
  • ¥ 199.0元
  • 市场价:199.0元

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: