filters

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package filters provide logic to handle binary data encoded with PDF filters, such as inline data images. Regular stream objects provide a Length information, but inline data images don't, which requires to detect the End of Data marker, which depends on the filter. This package only parse encoded content. See pdfcpu/filter for an alternative to also encode data.

Index

Constants

View Source
const (
	ASCII85   = "ASCII85Decode"
	ASCIIHex  = "ASCIIHexDecode"
	RunLength = "RunLengthDecode"
	LZW       = "LZWDecode"
	Flate     = "FlateDecode"
	DCT       = "DCTDecode"
	CCITTFax  = "CCITTFaxDecode"
)

PDF defines the following filters. See also 7.4 in the PDF spec, and 8.9.7 - Inline Images

Variables

This section is empty.

Functions

func NewFilter

func NewFilter(name string, params map[string]int, src io.Reader) (io.Reader, error)

NewFilter wraps the given `src` to decode the according to the given filter `name`, or returns an error it the filter is not supported.

Types

type Skipper

type Skipper interface {
	// Skip reads the input data and look for an EOD marker.
	// It returns the number of bytes read to go right after EOD.
	// Note that, due to buferring, the given reader may actually have read a bit more.
	Skip(io.Reader) (int, error)
}

Skipper is able to detect the end of a filtered content. Since some filters take additional parameters, skippers should be directly created by their concrete types, but this interface is exposed as a convenience.

func SkipperFromFilter

func SkipperFromFilter(name string, params map[string]int) (Skipper, error)

SkipperFromFilter select the right skipper. An error is returned if and only if the filter is not supported

type SkipperAscii85

type SkipperAscii85 struct{}

func (SkipperAscii85) Skip

func (f SkipperAscii85) Skip(encoded io.Reader) (int, error)

Skip implements Skipper for an ASCII85Decode filter.

type SkipperAsciiHex

type SkipperAsciiHex struct{}

func (SkipperAsciiHex) Skip

func (f SkipperAsciiHex) Skip(encoded io.Reader) (int, error)

Skip implements Skipper for an ASCIIHexDecode filter.

type SkipperCCITT

type SkipperCCITT struct {
	Params ccitt.CCITTParams
}

func (SkipperCCITT) Skip

func (f SkipperCCITT) Skip(encoded io.Reader) (int, error)

Skip implements Skipper for a CCITT filter.

type SkipperDCT

type SkipperDCT struct{}

func (SkipperDCT) Skip

func (d SkipperDCT) Skip(encoded io.Reader) (int, error)

Skip implements Skipper for DCT filter (JPEG).

type SkipperFlate

type SkipperFlate struct{}

func (SkipperFlate) Skip

func (f SkipperFlate) Skip(encoded io.Reader) (int, error)

Skip implements Skipper for a Flate filter.

type SkipperLZW

type SkipperLZW struct {
	EarlyChange bool // In PDF, written as an integer. Default value: 1 (true).
}

func (SkipperLZW) Skip

func (f SkipperLZW) Skip(encoded io.Reader) (int, error)

Skip implements Skipper for an LZWDecode filter.

type SkipperRunLength

type SkipperRunLength struct{}

func (SkipperRunLength) Skip

func (f SkipperRunLength) Skip(encoded io.Reader) (int, error)

Skip implements Skipper for an RunLengthDecode filter.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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