NormalizeLZWStreams
Document Management
Description
Rewrites every stream filtered with LZWDecode as FlateDecode. Decode parameters Predictor, Columns, Colors, and BitsPerComponent are honored during decompression, a single LZWDecode /Filter entry is replaced wholesale, and inside filter arrays the LZWDecode entry is swapped in place so chained filters keep their order
LZW decoding honours the standard code-width transitions for both EarlyChange values, including dictionary resets and the end-of-data code
Syntax
Delphi
Function TPDFlib.NormalizeLZWStreams: Integer;Return values
The number of streams converted, or 0 when the selected document contains no LZWDecode streams
Remarks
LZWDecode dates back to PDF 1.0 and several strict output profiles and downstream tools favor FlateDecode, so run this pass before saving when normalizing legacy documents. The conversion is lossless: decompressed bytes are re-compressed with Deflate and the stream dictionary keeps its remaining entries
Example
PDF.LoadFromFile('legacy.pdf', '');
PDF.NormalizeLZWStreams;
PDF.SaveToFile('legacy-normalized.pdf');