filter

package
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 21, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package filter implements the PDF stream decode filters of ISO 32000-1 §7.4 that text extraction needs: FlateDecode, LZWDecode, ASCIIHexDecode, ASCII85Decode and RunLengthDecode, with the PNG and TIFF predictors. The image codecs (DCTDecode, JPXDecode, CCITTFaxDecode, JBIG2Decode) are not stream filters here: Apply rejects them, and ImageCodec identifies them so a caller can stop a filter chain at the codec and hand the still-encoded image data to a decoder.

The package knows nothing about the PDF object model: callers extract /DecodeParms fields into Params.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Apply

func Apply(r io.Reader, filterName string, p Params) (io.Reader, error)

Apply wraps r with the named decode filter. The returned reader fails on malformed data rather than panicking; callers bound total output.

func ImageCodec added in v0.5.0

func ImageCodec(name string) (string, bool)

ImageCodec reports whether name (full or abbreviated) is one of the image codecs, returning its full name: DCTDecode, JPXDecode, CCITTFaxDecode or JBIG2Decode.

Types

type Params

type Params struct {
	Predictor        int
	Colors           int
	BitsPerComponent int
	Columns          int
	NoEarlyChange    bool // LZW /EarlyChange 0 (the non-default variant)
}

Params carries the /DecodeParms fields a filter consumes. The zero value means the spec defaults (Predictor 1, Colors 1, BitsPerComponent 8, Columns 1, EarlyChange 1).

type Releaser added in v0.4.0

type Releaser interface {
	Release()
}

Releaser is implemented by readers that hold pooled resources. A caller that has finished with a stream calls Release to return them; a reader that is never released is simply garbage collected. Reads after Release fail.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL