Documentation
¶
Overview ¶
Package filter contains PDF filter implementations.
Index ¶
Constants ¶
const ( ASCII85 = "ASCII85Decode" ASCIIHex = "ASCIIHexDecode" RunLength = "RunLengthDecode" LZW = "LZWDecode" Flate = "FlateDecode" CCITTFax = "CCITTFaxDecode" JBIG2 = "JBIG2Decode" // TODO DCT = "DCTDecode" JPX = "JPXDecode" // TODO )
PDF defines the following filters. See also 7.4 in the PDF spec.
const ( // PredictorNo disables prediction. PredictorNo = 1 // PredictorTIFF applies TIFF prediction to every row. PredictorTIFF = 2 // PredictorNone applies the PNG none filter to every row. PredictorNone = 10 // PredictorSub applies the PNG sub filter to every row. PredictorSub = 11 // PredictorUp applies the PNG up filter to every row. PredictorUp = 12 // PredictorAverage applies the PNG average filter to every row. PredictorAverage = 13 // PredictorPaeth applies the PNG Paeth filter to every row. PredictorPaeth = 14 // PredictorOptimum selects the optimum PNG filter for each row. PredictorOptimum = 15 )
PDF allows a prediction step prior to compression applying TIFF or PNG prediction. Predictor algorithm.
const ( // PNGNone identifies the PNG none filter. PNGNone = 0x00 // PNGSub identifies the PNG sub filter. PNGSub = 0x01 // PNGUp identifies the PNG up filter. PNGUp = 0x02 // PNGAverage identifies the PNG average filter. PNGAverage = 0x03 // PNGPaeth identifies the PNG Paeth filter. PNGPaeth = 0x04 )
For predictor > 2 PNG filters (see RFC 2083) get applied and the first byte of each pixelrow defines the prediction algorithm used for all pixels of this row.
const DefaultMaxDecodeBytes int64 = 512 << 20 // 512 MiB
Variables ¶
var ErrDecodeLimitExceeded = errors.New("filter decode limit exceeded")
ErrDecodeLimitExceeded signals that decoded filter output exceeds the configured decode limit.
var ErrUnsupportedFilter = errors.New("filter not supported")
ErrUnsupportedFilter signals unsupported filter encountered.
Functions ¶
func IsCorruptFlateInput ¶ added in v0.14.0
IsCorruptFlateInput reports whether err contains a Flate corrupt-input error.
func SupportsDecodeParms ¶ added in v0.9.0
SupportsDecodeParms returns true if filterName supports decode parameters.
Types ¶
type Filter ¶
type Filter interface {
Encode(r io.Reader) (io.Reader, error)
Decode(r io.Reader) (io.Reader, error)
// DecodeLength will decode at least maxLen bytes. For filters where decoding
// parts doesn't make sense (e.g. DCT), the whole stream is decoded.
// If maxLen < 0 is passed, the whole stream is decoded.
DecodeLength(r io.Reader, maxLen int64) (io.Reader, error)
}
Filter defines an interface for encoding/decoding PDF object streams.