file

package
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: May 28, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package file builds upon a parser to read an existing PDF file, producing a tree of PDF objets. See pacakge reader for an higher level of processing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsString

func IsString(o model.Object) (string, bool)

IsString return the string and true if o is a StringLitteral (...) or a HexadecimalLitteral <...>. Note that the string is unespaced (for StringLitteral) or decoded (for HexadecimalLitteral), but is not always UTF-8.

Types

type Configuration

type Configuration struct {
	// Either owner or user password.
	// TODO: We don't support changing permissions,
	// so both password acts the same.
	Password string
}

func NewDefaultConfiguration

func NewDefaultConfiguration() *Configuration

type FDFFile

type FDFFile struct {
	XrefTable

	Version string

	Root model.ObjIndirectRef
}

FDFFile is an in-memory version of a .fdf file, used to fill PDF forms.

func ReadFDF

func ReadFDF(rs io.ReadSeeker) (FDFFile, error)

ReadFDF process a FDF file, loading objects in memory.

func ReadFDFFile

func ReadFDFFile(file string) (FDFFile, error)

ReadFDFFile is the same as ReadFDF, but takes a file name as input.

type IncorrectPasswordErr

type IncorrectPasswordErr string

IncorrectPasswordErr is returned when the given password is not correct.

func (IncorrectPasswordErr) Error

func (ip IncorrectPasswordErr) Error() string

type PDFFile

type PDFFile struct {
	XrefTable

	// The PDF version the source is claiming to us as per its header.
	HeaderVersion string

	// AdditionalStreams (array of IndirectRef) is not described in the spec,
	// but may be found in the trailer :e.g., Oasis "Open Doc"
	AdditionalStreams parser.Array

	// Reference to the Catalog root dictionnary
	Root parser.IndirectRef

	// Optionnal reference to the Info dictionnary, containing metadata.
	Info *parser.IndirectRef

	// ID is found in the trailer, and used for encryption
	ID [2]string

	// Encryption dictionary found in the trailer. Optionnal.
	Encrypt *model.Encrypt
}

PDFFile represents a parsed PDF file. It is mainly composed of a store of objects (model.Object), identified by their reference (model.ObjIndirectRef). It usually requires more processing to be really useful: see the packages 'reader' and 'model'.

func Read

func Read(rs io.ReadSeeker, conf *Configuration) (PDFFile, error)

Read process a PDF file, reading the xref table and loading objects in memory.

func ReadFile

func ReadFile(file string, conf *Configuration) (PDFFile, error)

ReadFile is the same as Read, but takes a file name as input.

type XrefTable

type XrefTable map[int]model.Object

XrefTable maps object numbers to objects.

func (XrefTable) ResolveObject

func (table XrefTable) ResolveObject(o parser.Object) parser.Object

ResolveObject use the xref table to resolve indirect reference. If the reference is invalid, the ObjNull{} is returned. As convenience, direct objects may also be passed and will be returned as it is.

Jump to

Keyboard shortcuts

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