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 | Failed — no document is open or no page is selected. |
|---|---|
| 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