使用TCPDF生成的UTF-8 PDF在Adobe Acrobat中显示正常,但在Illustrator和Google预览中已损坏

使用TCPDF生成的UTF-8 PDF在Adobe Acrobat中显示正常,但在Illustrator和Google预览中已损坏

问题描述:

I use PHP and TCPDF to generate online invoices encoded in utf8. I've created font definition files following the tutorial on the tcpdf website using PT-sans .ttf file.

Generated pdf files look fine (accents are displayed correctly) when opened with Adobe Reader. But as soon as you open the pdf file with Adobe Illustrator, you'll see a mix of normal ascii characters and missing characters signs. When opened as attachment in the gmail preview, no text is displayed at all, just images will show up.

I also get unconsistent behavior with Foxit reader. It was ok on one computer (with font installed), but corrupted on another (without the font installed).

Illustrator (on the left) and Foxit reader printscreen: http://dl.dropbox.com/u/14647415/illustrator%20and%20foxit.jpg

Here is a copy of the corrupted file: http://dl.dropbox.com/u/14647415/2011040-3.pdf

PDF's size is ±200kB, so font seems to be embeded correctly.

This seems to happen with any utf8 font, embeded with procedure described on the tcpdf website. When I tried the core cid fonts, that came with the tcpdf library, accented characters were missing, or have been replaced with ?, but the overal layout and text were ok in Illustrator, too. Attached utf-8 fonts like Dejavusans are showing up corrupted, too.

I use 'UTF-8' as a param passed into tcpdf constructor.

class XTCPDF extends TCPDF {

function __construct(){
    parent::__construct('P', 'mm', 'A4', true, 'UTF-8', false);
    ...
}
...

}

Do you have any ideas on what could be causing this?

Thank you very much in advance.

p.

我使用PHP和TCPDF生成以utf8编码的在线发票。 我已经使用PT-sans .ttf文件在tcpdf网站上的教程之后创建了字体定义文件。 p>

使用Adobe Reader打开时,生成的pdf文件看起来很好(重音显示正确)。 但是一旦用Adobe Illustrator打开pdf文件,就会看到正常的ascii字符和缺少字符符号的混合。 当在gmail预览中作为附件打开时,根本不会显示任何文本,只会显示图像。 p>

我对Foxit阅读器也有不一致的行为。 它在一台计算机上安装了(安装了字体),但在另一台计算机上损坏(没有安装字体)。 p>

Illustrator(左侧)和福昕阅读器printcreen: http://dl.dropbox.com/u/14647415/illustrator%20and%20foxit.jpg p>

以下是损坏文件的副本: http://dl.dropbox.com/u/14647415/2011040-3.pdf p>

PDF的大小为±200kB,因此字体似乎正确嵌入。 p>

这似乎与任何utf8字体一样,嵌入 使用tcpdf网站上描述的程序。 当我尝试使用tcpdf库附带的核心cid字体时,重音字符丢失了,或者已被替换为?,但是在Illustrator中也可以使用整体布局和文本。 像Dejavusans这样附加的utf-8字体也显示已损坏。 p>

我使用'UTF-8'作为传递给tcpdf构造函数的参数。 p>

类XTCPDF扩展TCPDF { p>

  function __construct(){
 parent :: __ construct('P','mm','A4',true,'UTF  -8',false); 
 ... 
} 
 ... 
  code>  pre> 
 
 

} p>

你有什么想法可以引起这种情况吗? p>

非常感谢你提前。 p>

p。 p> DIV>

Problem was obviously caused by TCPDF automatically subsetting the font. This caused problems with charset (characters were "shifted", '0' interpreted as 'A' etc.) in aplications other than Acrobat.

Solution to this is setting:

$pdf->setFontSubsetting(false);

and subsetting your font manually to reduce the resulting file size, based on charset you want to use.