TCPDF - 在iPad上查看PDF时不会显示嵌入的ttf字体 [英] TCPDF - embedded ttf fonts not showing when PDF is viewed on iPad

查看:223
本文介绍了TCPDF - 在iPad上查看PDF时不会显示嵌入的ttf字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个使用tcpdf动态创建PDF的网站,并将这些字体嵌入到PDF中。用户可以从Arial,Verdana等一系列标准字体中进行选择。然后系统直接从我的服务器中选择一种ttf字体,并使用下面的代码进行嵌入。具有该字体的文本在大多数pdf查看器中都可以看到,但是 iPad / iPhone的查看器没有显示它。我下载了一个新的(随机)Arial.ttf版本作为测试(不确定在文件中的差异,但似乎现在显示罚款。

我需要这样做的一些字体,但在黑暗中拍摄,因为我不知道什么字体可能会导致它不被嵌入。有没有人知道什么在ttf字体会导致它不被显示?在其他浏览器和显示器上显示可以嵌入到Acrobat文档属性中?

谢谢

  $ fontname = $ pdf-> addTTFfont('/ tcpdf / fonts / custom /'.$ ttfFile。'。ttf','TrueTypeUnicode','',32); 


使用字体

pre $ code > $ pdf-> SetFont($ fontname,'',$ fontPoints,'','false');



$ =h2_lin>解决方案

b $ b

 <?php 
...
//错误
$ pdf-> SetFont($ fontname,'',$ fontPoints,'','false');
$ b $ // Right
$ pdf-> SetFont($ fontname,'',$ fontPoints,'',true);
...
?>

为什么会这样?

因为它嵌入了整个字体,不仅是一个子集。
诀窍是将方法$ pdf-> SetFont()中的参数$ subset设置为true。


http:// www.tcpdf.org/doc/code/classTCPDF.html#a471562985997be1573d387f0aeae6964



PDF正与



iPad(IOS 7),iPhone(IOS 7),Windows 7,MACOSX 10.9。

创建



Apache 2在MAC 10.9,PHP 5.3.x,TCPDF v6.0.078上

文件



示例PDF和a PHP脚本来创建它


I've created a website that dynamically creates PDF's using tcpdf and embeds the fonts into the PDF. The user can select from a range of standard fonts like Arial, Verdana etc. Then the system chooses a ttf font directly from my server and embeds using the code below. The text with that font could be seen fine on most pdf viewers but iPad/iPhone's viewer wasn't displaying it. I downloaded a new (random) version of Arial.ttf as a test(not sure of the difference in the file, but it seems to display fine now.

I need to do this for a number of fonts but am shooting in the dark a bit because I don't know what in the font might cause it not to be embedded. Does anyone know what in the ttf fonts would cause it not to be displays? Shows fine on other viewers and shows to be embedded in Acrobat document properties?

Thanks

$fontname = $pdf->addTTFfont('/tcpdf/fonts/custom/'.$ttfFile.'.ttf', 'TrueTypeUnicode', '', 32);

// use the font

$pdf->SetFont($fontname, '', $fontPoints, '', 'false');

解决方案

Your parameter for $subset is wrong. You set it to 'false' (with the quotes). It should be boolean true.

    <?php
          ...
          // Wrong
          $pdf->SetFont($fontname, '', $fontPoints, '', 'false');

          // Right
          $pdf->SetFont($fontname, '', $fontPoints, '', true); 
          ...
    ?>

Why does it work?

Because it embeds the whole font, not only a subset. The trick is to set the parameter $subset in method $pdf->SetFont() to true.

http://www.tcpdf.org/doc/code/classTCPDF.html#a471562985997be1573d387f0aeae6964

PDF is working with

iPad (IOS 7), iPhone (IOS 7), Windows 7, MACOSX 10.9.

My environment for PDF Creation

Apache 2 on MAC 10.9, PHP 5.3.x, TCPDF v6.0.078

Files

Example PDF and a PHP Script to create it

这篇关于TCPDF - 在iPad上查看PDF时不会显示嵌入的ttf字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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