SetCompressionLevel

Document properties, Optimisation

Description

Selects the deflate compression level used for every compression the library performs from that point on.

Syntax

Delphi

Function TPDFlib.SetCompressionLevel(Level: Integer): Integer;

Parameters

Level0 restores the default engine (the SIMD-accelerated fast path on 64-bit builds); 1 to 9 selects a classic zlib level, where 1 favours throughput and 9 squeezes the output smallest.

Return values

0Invalid level.
1Level selected.

Remarks

The setting is process-wide and applies to newly written content streams, packed object streams, embedded data and every other deflate operation. Combine level 9 with RecompressStreams to shrink existing documents for archival, or level 1 for bulk throughput where size is secondary.

Example

PDF.SetCompressionLevel(9);
PDF.RecompressStreams;
PDF.SaveToFile('archive.pdf');
PDF.SetCompressionLevel(0);

See also

GetCompressionLevel, RecompressStreams, CompressContent, FlateZlibNgBackend