Documentation
¶
Overview ¶
Package filters provides PDF stream decompression filters.
PDF streams can be compressed using various algorithms. This package implements the standard PDF decompression filters.
Supported Filters ¶
FlateDecode (zlib/deflate):
decoded, err := filters.FlateDecode(data, params)
FlateDecode supports PNG predictors for improved compression of image data. The Predictor parameter specifies the algorithm:
- 1: No prediction (default)
- 2: TIFF Predictor 2
- 10-15: PNG predictors (None, Sub, Up, Average, Paeth)
ASCIIHexDecode:
decoded, err := filters.ASCIIHexDecode(data)
Decodes hexadecimal-encoded data. Whitespace is ignored.
ASCII85Decode:
decoded, err := filters.ASCII85Decode(data)
Decodes ASCII base-85 encoded data (also known as Ascii85).
Decode Parameters ¶
Filters accept a Params map for additional parameters:
params := filters.Params{
"Predictor": 12,
"Columns": 100,
"Colors": 3,
}
decoded, err := filters.FlateDecode(data, params)
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ASCII85Decode ¶
ASCII85Decode decodes ASCII base-85 (Ascii85) encoded data. Each group of 5 ASCII characters (! to u, values 33-117) represents 4 bytes. The special character 'z' represents four zero bytes. The sequence ~> marks end of data.
func ASCIIHexDecode ¶
ASCIIHexDecode decodes ASCII hexadecimal encoded data. Each pair of hexadecimal digits (0-9, A-F, a-f) represents one byte. Whitespace is ignored, and > marks end of data.
func CCITTFaxDecode ¶ added in v1.6.0
CCITTFaxDecode decodes CCITT Group 3/4 fax compressed data. This is commonly used for bi-level (black and white) images in PDFs, particularly for scanned documents.
Parameters from the PDF decode parameters dictionary:
- K: Group selector (-1=Group4, 0=Group3 1D, >0=Group3 2D)
- Columns: Image width in pixels (default 1728)
- Rows: Image height in pixels (default 0, uses AutoDetectHeight)
- BlackIs1: Bit interpretation (default false, maps to ccitt.Options.Invert)