TCPDF pdf中的特定字体 [英] Specific fonts in TCPDF pdf

查看:323
本文介绍了TCPDF pdf中的特定字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以告诉我我做错了什么吗?我需要TCPDF生成的pdf中的Arial字体. 首先,我尝试使用它: 1)我从Windows字体caltalog获得了Arial,并将其放在TCPDF目录中. 2)接下来,我在脚本中写道:

Can somebody tell me what i am doing wrong? I need Arial font in my pdf generated by TCPDF. First I've tried to use that : 1) I got Arial from windows fonts caltalog and put it in TCPDF directory. 2) Next I wrote in script :

$fontname = $pdf->addTTFfont('../lib/tcpdf/arial.ttf', '', '', 32);

之后,在tcpdf/fonts中出现3个文件(arial.ctg.z,arial.php和arial.z).我以为一切都很好,但是如果在TCPDF中,我可以通过以下方式使用此字体:

After that in tcpdf/fonts appears 3 files (arial.ctg.z , arial.php and arial.z). I thought that everything was ok but if in TCPDF i use this font by:

$pdf->SetFont('arial', '', 16);

文档中的字体确实是阿拉伯字体,但没有波兰语特定的歌唱(±ęłżńź)

Font in document is indeed arial but without polish specific sings (ąęłżńź)

我也尝试过自己准备字体: 我下载了ttf2afm和makefontuni.php脚本,然后在命令行中这样写:

I've tried also prepare font by yourself : I downloaded ttf2afm and makefontuni.php script then in command line I wrote this:

ttf2ufm -a arial.ttf
php -q makefontuni.php arial.ttf arial.ufm

该命令还给了我3个文件(arial.ctg.z,arial.php和arial.z),但最终情况与以前相同.

that command gave me also 3 files (arial.ctg.z , arial.php and arial.z) but final situation is the same like before.

我承认所有写入pdf的数据都在UTF-8中,而TCPDF构造是这样的:

I've admit that all data writing to pdf is in UTF-8 and TCPDF construct is like this :

$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'utf-8', false);

我不知道我在做什么错. :(

I don't know what am i doing wrong. :(

推荐答案

如果要使用自定义字体,请使用此工具

If you want to use a custom font use this tool

http://www.xml-convert.com /en/convert-tff-font-to-afm-pfa-fpdf-tcpdf

获得生成的文件时,只需将它们移动到/fonts目录并使用相同的名称,设置font-name属性.

when you get the generated files just move them to the /fonts directory and with the same name they have, set the font-name attribute.

这篇关于TCPDF pdf中的特定字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆