【发布时间】:2019-07-03 08:45:56
【问题描述】:
Foxit SDK 中的 DeletePage 功能允许从 PDF 中删除页面。当删除页面并保存文档时,输出文档的文件大小(页数较少)大于原始文档。
这可以通过 SDK 附带的 PDF 示例应用程序看到:
$ ./simple_sample/bin/rel_gcc/pdfpage_organization
...
Success: Use <rb> mode to open the file InsertPages.pdf and associate it with a stream.
Success: Create the file object.
Success: Open file successfully .
Success: Load PDF document successfully.
Success: Get page with index 1.
Success: Delete page with index 1.
Using extension implementation to open the file.
Success: Use <wb> mode to open the file SourcePage_delete.pdf and associate it with a stream.
Success: Create the file object.
Success: The PDF document save to SourcePage_delete.pdf.
检查输出:
ll simple_sample/input_files/SourcePage.pdf -rw-r--r--@ 1 位 Richard Staff 92K 2013 年 12 月 17 日 simple_sample/input_files/SourcePage.pdf
ll simple_sample/output_files/pdfpage_organization/SourcePage_delete.pdf -rw-r--r--@ 1 理查德员工 96K 6 月 23 日 10:22 simple_sample/output_files/pdfpage_organization/SourcePage_delete.pdf
SourcePage_delete.pdf 确实像预期的那样少了一页,但大了 4k。我可以从 100 页的文档中删除 99 页得到相同的结果,即文件大小不反映页数。
【问题讨论】:
-
我很想知道文档的内部结构是什么样的。您可以在某处发布之前和之后的文件吗?
-
在增量更新模式下执行删除和保存操作是可能的(我不知道福昕SDK)。在这种情况下,页面仅被标记为已删除,并添加了额外的结构,因此最终大小大于原始大小。
-
我可以想象是这样。是否有另一种模式会强制删除页面中包含的结构?
-
这可能有几个原因。也许原始 PDF 缺少一些必需的元素,并且在保存修改后的 PDF 的过程中,这个缺少的元素已自动添加到 PDF 中“修复”它。或者,某些对象可能在页面删除之前已被压缩,并且在页面删除期间/之后,该对象不再被压缩(尽管在这种情况下文件大小增加很可能超过 4k)。
标签: pdf pdf-generation foxit