EncodeStream(CosStream, ReadOnlySpan, CompressionLevel) Method

Definition

Namespace Broadside
Assembly Broadside.dll

Replaces the data of stream with data encoded through the filters its Filter entry names, so that DecodeStream(CosStream) gives data back.

public void EncodeStream(CosStream stream, ReadOnlySpan<byte> data, CompressionLevel compressionLevel = CompressionLevel.Optimal)

Parameters

stream
CosStream

A stream of this document, or a new one; set its Filter and DecodeParms entries first.

data
ReadOnlySpan<Byte>

The decoded data.

compressionLevel
CompressionLevel

How much encoders that compress, such as FlateDecode's, compress.

Remarks

ISO 32000-2 §7.3.8.2 and §7.4. Encoders come from the engine's options (UseStreamEncoder(IStreamEncoder)): by default FlateDecode, ASCIIHexDecode, ASCII85Decode and RunLengthDecode. They run in the reverse of the entry's order (§7.4.1), and the predictor a FlateDecode or LZWDecode filter's parameters name (§7.4.4.4: TIFF 2, PNG 10 to 15) is applied before it. A stream without a Filter entry takes the data as it is.

The stream's EncodedData is replaced, which marks it changed; its dictionary is not changed.

FlateDecode is PDF 1.2 (§7.4.4), JBIG2Decode PDF 1.4 (§7.4.7) and JPXDecode PDF 1.5 (§7.4.9; Table 6): once a stream is encoded with one of them, a save of a document of an earlier version raises the version, or refuses in strict mode.