一些额外的(兆)字节可以很容易地从 PDF 中挤出。例如,是一个众所周知的“PDF32000_2008.pdf”优化够不够?文件大小为8,995,189
字节。它使用对象和外部参照流,(几乎)没有图像,一切都紧凑。或者不是吗?
看一个页面字典:
Dict:9 [1 0 R]
. /Annots Array:3
. /Contents Stream:3 [2 0 R]
. /CropBox Array:4
. /MediaBox Array:4
. /Parent Dict:4 [124248 0 R]
. /Resources Dict:4
. /Rotate 0 (Number)
. /StructParents 2 (Number)
. /Type Page (Name)
Rotate 0
是默认的,为什么会有这个?什么是CropBox
那里有什么用?它默认为MediaBox
,并且本文档中没有页面包含CropBox
以外MediaBox
。为什么是MediaBox
那里?它是可继承的,所有页面的大小相同,因此将其移动到页面树根!有 756 页,即冗余(或无用)信息被复制了 756 次。
看一下典型的Annotation字典:
Dict:6 [3548 0 R]
. /A Dict:2
. . /S URI (Name)
. . /URI http://www.iso.org/iso/iso_catalogue/... (String)
. /Border Array:3
. . [0] 0 (Number)
. . [1] 0 (Number)
. . [2] 0 (Number)
. /Rect Array:4
. . [0] 82.14 (Number)
. . [1] 576.8 (Number)
. . [2] 137.1 (Number)
. . [3] 587.18 (Number)
. /StructParent 3 (Number)
. /Subtype Link (Name)
. /Type Annot (Name)
本文档中有数千(也许 > 10'000?)链接注释。/Type
key 是可选的,为什么它在那里?它们是不可见的矩形,您认为它们的放置精度与点数无关吗?将其舍入为整数。
看一下典型页面内容流的片段,显示运算符的文本:
[(w)7(ed)-6( b)21(u)1(t shal)-6(l no)-6(t b)-6(e)1( ed)-6(ite)-6(d)1( un)-6(less the typef)23(aces wh)-6(ich )]TJ
字距调整小于一些价值几乎是看不见的。这value可能会有争议,这就像 JPEG 压缩质量级别 - 有些人可以接受,有些人则不同意。我认为非常保守的估计(即保留大部分质量),一般人看不到效果,就是可以省略绝对值小于10的字距调整。 (当然,必须注意保持合理性)。 (我什至没有提到有文件分数字距调整精确到小数点后 3-6 位!但不在这个文件中)
并且,通过上述优化,文件大小变为7,982,478
字节。减少了一兆字节。这当然不是限制,也许还有其他隐藏得更好的优化来源。