0

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 理查员工 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 Jun 23 10:22 simple_sample/output_files/pdfpage_organization/SourcePage_delete.pdf

SourcePage_delete.pdf 确实像预期的那样少了一页,但大了 4k。我可以从 100 页文档中删除 99 页得到相同的结果,即文件大小不反映页数。

4

2 回答 2

1

根据您提供的示例文档和@MihaiIancu 的评论,您正在保存增量 PDF 更新,它基本上只是将新信息附加到现有文件的末尾。

根据 Foxit SDK 站点,该函数FSPDF_Doc_StartSaveToFile为第三个参数设置一个标志,即FSPDF_SAVEFLAG_INCREMENTAL、或。在您的情况下,我认为这应该可以满足您的要求。如果您不直接使用此函数,则仍希望有一个采用这些参数之一的包装器。FSPDF_SAVEFLAG_NOORIGINALFSPDF_SAVEFLAG_REMOVESECURITYFSPDF_SAVEFLAG_OBJECTSTREAMFSPDF_SAVEFLAG_NOORIGINAL

于 2014-06-23T20:20:46.000 回答
0

在最新的 Foxit PDF SDK 6.4 for Linux 中,save 方法支持 e_SaveFlagRemoveRedundantObjects。通常当您删除一个页面时,它只是在 PDF 结构中被引用。如果设置此标志,它只会删除 PDF 中未引用的任何对象。

于 2019-07-03T00:45:56.167 回答