PHP + tcpdf:如何使用本地语言生成时减少文件大小


PHP + tcpdf: How can I reduce file size when generate with local language

现在我的web应用程序使用tcpdf类转换所有pdf文件(英文)和文件大小约为500K。

但是当我将字体样式更改为我的本地语言(Free-serif)时,文件大小超过1M(图片、表格不变)

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

您确实应该阅读TCPDF字体文档。所发生的情况是,您指定的字体嵌入到PDF中。这将确保电脑上没有这种字体的人仍然能够看到你想要的文档。使用正确的字体)。

你可以使用AddFont/SetFont的$子集参数改变默认行为。

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字体