2011-04-18 115 views
0

现在我的web应用程序使用class tcpdf转换所有pdf文件(英文)和文件大小大约为500K。PHP + tcpdf:当使用本地语言生成时,如何缩小文件大小

但是,当我将字体样式更改为我的本地语言(自由衬线),则文件大小超过1M (图片,表格不会更改)。

如果我切换回正常字体,文件大小很小,但非英文文本变得不可读。

谢谢

回答

2

你真的应该阅读TCPDF fonts documentation。会发生什么是您指定的字体嵌入在PDF中。这将确保在他们的计算机上没有该字体的人仍然能够按照您的意图查看文档(即使用正确的字体)。

您可以使用AddFont/SetFont的$ subset参数更改默认行为。

从TCPDF源的有关信息:

@param $subset (mixed) if true embed only a subset of the font (stores 
only the information related to the used characters); if false embedd full 
font; if 'default' uses the default value set using setFontSubsetting(). 
This option is valid only for TrueTypeUnicode fonts. If you want to enable 
users to change the document, set this parameter to false. If you subset 
the font, the person who receives your PDF would need to have your same 
font in order to make changes to your PDF. The file size of the PDF would 
also be smaller because you are embedding only part of a font. 

所以,如果你不想让你的PDF变得更大:坚持为在文档中规定的标准(核心)PDF字体。

+0

你说得对。谢谢 – dbBoy 2011-04-19 08:38:11