CompressPage
Page properties
Description
Compresses the content stream of the currently selected page using Flate (zlib). The behavior is identical to CompressContent but limited to a single page. Looping through every page with SelectPage and CompressPage produces the same result as one call to CompressContent, with the advantage that the application can report per-page progress in the UI.
Syntax
Delphi
function TPDFlib.CompressPage: Integer;ActiveX
Function PDFlib::CompressPage As LongDLL
int DLCompressPage(int InstanceID);Return values
| 0 | Failed — no document is open or no page is selected. |
|---|---|
| 1 | The page's content stream was compressed (or was already compressed and left as-is). |
Remarks
Already-compressed streams are skipped, so calling CompressPage twice on the same page is harmless. The Win64 build uses the bundled zlib-ng SIMD object set; the Win32 build uses the generic zlib-ng object set in zlib-compatible mode.
Example
// 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;See also
CompressContent, CompressImages, CompressFonts, SelectPage, PageCount