Documentation
¶
Overview ¶
Package file reads a PDF file through its cross-reference tables and appends incremental updates to it.
It reads what Chrome writes and what its own updates add: classic cross-reference tables, chained by /Prev. Cross-reference streams, compressed object streams and encryption are refused rather than half-read.
Index ¶
- Constants
- Variables
- type File
- func (f *File) Catalog() (object.Dictionary, *object.Reference, error)
- func (f *File) Generation(number int) int
- func (f *File) NewUpdate() *Update
- func (f *File) Object(number int) (object.Object, error)
- func (f *File) PageTree() (*PageTree, error)
- func (f *File) Resolve(value object.Object) (object.Object, error)
- func (f *File) ResolveArray(value object.Object) (object.Array, error)
- func (f *File) ResolveDictionary(value object.Object) (object.Dictionary, error)
- func (f *File) Size() int
- type Page
- type PageTree
- type Update
- type Written
Constants ¶
const (
// MaxObjectNumber is the largest object number a PDF may use (ISO 32000-1, Annex C).
MaxObjectNumber = 8388607
)
Variables ¶
var ErrUnsupported = fmt.Errorf("unsupported pdf feature: %w", altshiftErrors.ErrValidationError)
ErrUnsupported is a valid PDF feature this package does not read; it is a validation error, so an endpoint answers it as input it cannot take.
Functions ¶
This section is empty.
Types ¶
type File ¶
type File struct {
Data []byte
Trailer object.Dictionary
// contains filtered or unexported fields
}
File is a parsed PDF file as it stands after its last update; it caches what it reads, so it is not safe for concurrent use.
func Open ¶
Open reads the cross-reference chain from the last section back to the first, the newest entry for each object winning.
func (*File) Generation ¶
Generation is the generation the object with that number has in the newest revision.
func (*File) NewUpdate ¶
NewUpdate starts an update that numbers new objects past every number the file has used.
func (*File) Object ¶
Object returns the indirect object with that number, or nil for one that is free or absent, as the syntax has a reference to it read.
func (*File) Resolve ¶
Resolve follows references until it reaches a direct object; a reference whose generation is not the object's reads as null.
func (*File) ResolveArray ¶
ResolveArray resolves to an array.
func (*File) ResolveDictionary ¶
ResolveDictionary resolves to a dictionary, or a stream's dictionary.
type Page ¶
type Page struct {
Reference *object.Reference
Dictionary object.Dictionary
Inherited object.Dictionary
}
Page is a leaf of the page tree; Inherited holds the attributes it takes from its ancestors.
type PageTree ¶
PageTree is the document's pages in order, and the references of the tree's inner nodes.
type Update ¶
type Update struct {
// contains filtered or unexported fields
}
Update is an incremental update being assembled over a file: new and replaced objects, written after every byte that is already there.
func (*Update) Set ¶
Set writes the value as the object the reference names, replacing it if the file has one.