TCPDF字体没有加载,显示“...”在Adobe Reader上 [英] TCPDF font not embadding, showing "..." on adobe reader
问题描述
我使用这行代码在 TCPDF
中添加了许多字体
TCPDF_FONTS :: addTTFfont('fonts / ArchitectsDaughter.ttf','TrueTypeUnicode','',96);
$ pdf-> AddFont(ArchitectsDaughter);
许多其他字体正在工作,但是这个不起作用。
当我打开这个pdf到读者,它显示这样的错误
$ b
不能提取嵌入字体'ArchitectsDaughter'。
我正在导入 以下是完整的代码,如何使用字体文件pdf将会生成。 其他字体可以正常工作。不知道一些字体发生了什么。 首先通过 然后,激活字体: svg
pdf文件。
这里是 SVG 文件,我用pdf插入,你可以得到来自这里的PDF,这里是
$ fileName ='export';
$ uploadPath = Config :: get('constants.paths.uploads.images.base')。'/'。$ fileName。'。svg';
$ pdf = new TCPDF();
TCPDF_FONTS :: addTTFfont(dirname(dirname(dirname(dirname(__ FILE __))))。'/ vendor / font-awesome / fonts / ArchitectsDaughter.ttf','TrueTypeUnicode','',96 );
TCPDF_FONTS :: addTTFfont(dirname(dirname(dirname(dirname(__ FILE __))))。'/ vendor / font-awesome / fonts / Archivor.ttf','TrueTypeUnicode','',96);
$ pdf-> AddFont(Archivor);
$ pdf-> AddFont(ArchitectsDaughter);
$ pdf-> SetPrintHeader(false);
$ pdf-> SetPrintFooter(false);
$ pdf-> AddPage();
$ pdf-> ImageSVG($ uploadPath,$ x ='',$ y ='',$ w ='',$ h ='',$ link ='',$ align ='', $ palign ='',$ border = 0,$ fitonpage = true);
$ filename ='export.pdf';
$ pdf->输出($ filename,'D');
出口;
解决方案是什么?
设置字体TCPDF_FONTS: :addTTFfont()
或通过在字体目录中添加必要的文件dir(通过TCPDF字体转换器转换TTF文件,如 http://fonts.snm-portal.com )
$ b $ <然后,使用 writeHTML
函数编写一个unicode字符,从& #x开始,结束于;
例如:&#xf0c9;为f0c9(酒吧)图标( http://fontawesome.io/icon/bars/ ) :
$ pdf-> writeHTML('&#xf0c9;');
I added many fonts in TCPDF
using this line of code
TCPDF_FONTS::addTTFfont('fonts/ArchitectsDaughter.ttf', 'TrueTypeUnicode', '', 96);
$pdf->AddFont("ArchitectsDaughter");
Many other font is working but, this one is not working. When i opening this pdf into reader, it shows error like this
cannot extract the embedded font 'ArchitectsDaughter'. some character may not display or print correctly.
I am importing svg
file in pdf.
Here is the SVG file which i inserting in pdf, and you can get PDF from here and here is the font file.
Here is full code how pdf will generates.
$fileName='export';
$uploadPath = Config::get('constants.paths.uploads.images.base').'/'.$fileName.'.svg';
$pdf = new TCPDF();
TCPDF_FONTS::addTTFfont(dirname(dirname(dirname(dirname(__FILE__)))).'/vendor/font-awesome/fonts/ArchitectsDaughter.ttf', 'TrueTypeUnicode', '', 96);
TCPDF_FONTS::addTTFfont(dirname(dirname(dirname(dirname(__FILE__)))).'/vendor/font-awesome/fonts/Archivor.ttf', 'TrueTypeUnicode', '', 96);
$pdf->AddFont("Archivor");
$pdf->AddFont("ArchitectsDaughter");
$pdf->SetPrintHeader(false);
$pdf->SetPrintFooter(false);
$pdf->AddPage();
$pdf->ImageSVG($uploadPath, $x='', $y='', $w='', $h='', $link='', $align='', $palign='', $border=0, $fitonpage=true);
$filename = 'export.pdf';
$pdf->output($filename, 'D');
exit;
Other fonts working ok for me. Don't know what happening with some fonts. What is the solution for this?
First set up the font via TCPDF_FONTS::addTTFfont()
or by adding the necessary files in the fonts dir (convert the TTF file via a TCPDF font converter like http://fonts.snm-portal.com)
After that, activate the font:
$pdf->SetFont('FontAwesome','');
Then, write a unicode character with the writeHTML
function, starting with &#x and ending with ;
e.g.: for the f0c9 (bars) icon (http://fontawesome.io/icon/bars/):
$pdf->writeHTML('');
这篇关于TCPDF字体没有加载,显示“...”在Adobe Reader上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!