CompressPage
页面属性
描述
使用 Flate(zlib)压缩当前所选页面的内容流。其行为与 CompressContent 相同,但仅限于单个页面。使用 SelectPage 和 CompressPage 遍历每一页可获得与一次调用 CompressContent 相同的结果,并且应用程序可在 UI 中报告逐页进度
语法
Delphi
Function TPDFlib.CompressPage: Integer;
ActiveX
Function PDFlib::CompressPage() As Long
DLL
int DLCompressPage(int InstanceID);
返回值
| 0 | 失败 — 未打开文档或未选择页面 |
|---|---|
| 1 | 页面内容流已压缩(或已压缩并保持原样) |
备注
已压缩的流会被跳过,因此对同一页面两次调用 CompressPage 不会造成影响。Win64 构建使用随附的 zlib-ng SIMD 对象集;Win32 构建在 zlib 兼容模式下使用通用 zlib-ng 对象集
示例
// Compress every page individually so the UI can report progress
var
I, N: Integer;
begin
N := PDF.GetPageCount;
for I := 1 to N do
begin
PDF.SelectPage(I);
PDF.CompressPage;
ProgressBar1.Position := (I * 100) div N;
Application.ProcessMessages;
end;
PDF.SaveToFile('compressed.pdf');
end;另请参阅
CompressContent, CompressImages, CompressFonts, SelectPage, PageCount