pdf

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2019 License: GPL-3.0, GPL-3.0-only Imports: 22 Imported by: 2

Documentation

Index

Constants

View Source
const (
	KEYWORD_XREF           = Keyword("xref")
	KEYWORD_TRAILER        = Keyword("trailer")
	KEYWORD_OBJ            = Keyword("obj")
	KEYWORD_STREAM         = Keyword("stream")
	KEYWORD_R              = Keyword("R")
	KEYWORD_N              = Keyword("n")
	KEYWORD_NULL           = Keyword("null")
	KEYWORD_TRUE           = Keyword("true")
	KEYWORD_FALSE          = Keyword("false")
	KEYWORD_TEXT           = Keyword("BT")
	KEYWORD_TEXT_END       = Keyword("ET")
	KEYWORD_TEXT_FONT      = Keyword("Tf")
	KEYWORD_TEXT_MOVE_1    = Keyword("T*")
	KEYWORD_TEXT_MOVE_2    = Keyword("Td")
	KEYWORD_TEXT_MOVE_3    = Keyword("TD")
	KEYWORD_TEXT_POSITION  = Keyword("TJ")
	KEYWORD_TEXT_SHOW_1    = Keyword("Tj")
	KEYWORD_TEXT_SHOW_2    = Keyword("'")
	KEYWORD_TEXT_SHOW_3    = Keyword("\"")
	KEYWORD_BEGIN_BF_RANGE = Keyword("beginbfrange")
	KEYWORD_BEGIN_BF_CHAR  = Keyword("beginbfchar")
)
View Source
const (
	XrefTypeFreeObject = iota
	XrefTypeIndirectObject
	XrefTypeCompressedObject
)

Variables

View Source
var EncryptionError = errors.New("missing required encryption info")

errors

View Source
var EncryptionPasswordError = errors.New("incorrect password")
View Source
var EncryptionUnsupported = errors.New("unsupported encryption")
View Source
var EndOfArray = errors.New("end of array")
View Source
var EndOfDictionary = errors.New("end of dictionary")
View Source
var EndOfHexString = errors.New("end of hex string")
View Source
var EndOfString = errors.New("end of string")
View Source
var InvalidDictionaryKeyType = "invalid dictionary key type"

format errors and abnormalities

View Source
var InvalidHexStringChar = "invalid hex string character"
View Source
var InvalidNameEscapeChar = "invalid name escape character"
View Source
var InvalidOctal = "invalid octal in string"
View Source
var MissingDictionaryValue = "missing dictionary value"
View Source
var ReadError = errors.New("read failed")
View Source
var UnclosedArray = "unclosed array"
View Source
var UnclosedDictionary = "unclosed dictionary"
View Source
var UnclosedHexString = "unclosed hex string"
View Source
var UnclosedStream = "unclosed stream"
View Source
var UnclosedString = "unclosed string"
View Source
var UnclosedStringEscape = "unclosed escape in string"
View Source
var UnclosedStringOctal = "unclosed octal in string"
View Source
var UnnecessaryEscapeName = "unnecessary espace sequence in name"
View Source
var UnnecessaryEscapeString = "unnecessary espace sequence in string"
View Source
var Verbose *bool

Functions

func ASCII85Decode

func ASCII85Decode(data []byte) []byte

func ASCIIHexDecode

func ASCIIHexDecode(data []byte) []byte

func BytesToInt

func BytesToInt(b []byte) int

func Debug

func Debug(format string, a ...interface{})

func DecodeStream

func DecodeStream(filter string, data []byte, decode_parms Dictionary) []byte

func FlateDecode

func FlateDecode(data []byte, decode_parms Dictionary) []byte

func GetBits

func GetBits(d []byte, p int, n int) uint32

GetBits gets n bits from d starting at p

func IsHex

func IsHex(b byte) bool

IsHex returns true if the byte is a hex character

func LZWDecode

func LZWDecode(data []byte, decode_parms Dictionary) []byte

func Parse

func Parse(file_path string, password string, output_dir string) error

func ReadInt

func ReadInt(reader io.Reader, width int) (int, bool)

ReadInt reads width bytes from reader and returns the int64 value

func ReadInt64

func ReadInt64(reader io.Reader, width int) (int64, bool)

ReadInt reads width bytes from reader and returns the int64 value

func ReversePredictor

func ReversePredictor(data []byte, decode_parms Dictionary) []byte

func RunLengthDecode

func RunLengthDecode(data []byte) []byte

func SetBits

func SetBits(d []byte, p int, n int, v uint32)

SetBits sets n bits in d starting at p to the last n bits of v

Types

type Action

type Action Dictionary

func (Action) Extract

func (a Action) Extract(output *Output)

type Array

type Array []Object

func (Array) GetArray

func (a Array) GetArray(index int) (Array, bool)

func (Array) GetBool

func (a Array) GetBool(index int) (bool, bool)

func (Array) GetBytes

func (a Array) GetBytes(index int) ([]byte, bool)

func (Array) GetDictionary

func (a Array) GetDictionary(index int) (Dictionary, bool)

func (Array) GetInt

func (a Array) GetInt(index int) (int, bool)

func (Array) GetInt64

func (a Array) GetInt64(index int) (int64, bool)

func (Array) GetName

func (a Array) GetName(index int) (string, bool)

func (Array) GetNumber

func (a Array) GetNumber(index int) (Number, bool)

func (Array) GetObject

func (a Array) GetObject(index int) (Object, bool)

func (Array) GetStream

func (a Array) GetStream(index int) ([]byte, bool)

func (Array) GetString

func (a Array) GetString(index int) (string, bool)

func (Array) String

func (a Array) String() string

type CryptFilter

type CryptFilter interface {
	NewDecryptor(int, int) Decryptor
}

type CryptFilterAES

type CryptFilterAES struct {
	// contains filtered or unexported fields
}

AES

func (*CryptFilterAES) NewDecryptor

func (c *CryptFilterAES) NewDecryptor(n int, g int) Decryptor

type CryptFilterNone

type CryptFilterNone struct{}

No encryption

func (*CryptFilterNone) NewDecryptor

func (c *CryptFilterNone) NewDecryptor(n int, g int) Decryptor

type CryptFilterRC4

type CryptFilterRC4 struct {
	// contains filtered or unexported fields
}

RC4

func (*CryptFilterRC4) NewDecryptor

func (c *CryptFilterRC4) NewDecryptor(n int, g int) Decryptor

type Decryptor

type Decryptor interface {
	Decrypt([]byte)
}

type DecryptorAES

type DecryptorAES struct {
	// contains filtered or unexported fields
}

func (*DecryptorAES) Decrypt

func (d *DecryptorAES) Decrypt(data []byte)

type DecryptorNone

type DecryptorNone struct{}

func (*DecryptorNone) Decrypt

func (d *DecryptorNone) Decrypt(data []byte)

type DecryptorRC4

type DecryptorRC4 struct {
	// contains filtered or unexported fields
}

func (*DecryptorRC4) Decrypt

func (d *DecryptorRC4) Decrypt(data []byte)

type Dictionary

type Dictionary map[string]Object

func (Dictionary) GetArray

func (d Dictionary) GetArray(key string) (Array, bool)

func (Dictionary) GetBool

func (d Dictionary) GetBool(key string) (bool, bool)

func (Dictionary) GetBytes

func (d Dictionary) GetBytes(key string) ([]byte, bool)

func (Dictionary) GetDictionary

func (d Dictionary) GetDictionary(key string) (Dictionary, bool)

func (Dictionary) GetInt

func (d Dictionary) GetInt(key string) (int, bool)

func (Dictionary) GetInt64

func (d Dictionary) GetInt64(key string) (int64, bool)

func (Dictionary) GetName

func (d Dictionary) GetName(key string) (string, bool)

func (Dictionary) GetNameTreeMap

func (d Dictionary) GetNameTreeMap(key string) Array

func (Dictionary) GetNumber

func (d Dictionary) GetNumber(key string) (Number, bool)

func (Dictionary) GetObject

func (d Dictionary) GetObject(key string) (Object, bool)

func (Dictionary) GetPageTree

func (d Dictionary) GetPageTree(key string) ([]Dictionary, bool)

func (Dictionary) GetReference

func (d Dictionary) GetReference(key string) (*Reference, bool)

func (Dictionary) GetStream

func (d Dictionary) GetStream(key string) ([]byte, bool)

func (Dictionary) GetString

func (d Dictionary) GetString(key string) (string, bool)

func (Dictionary) ResolveKids

func (d Dictionary) ResolveKids(resolved_kids map[int]interface{}) []Dictionary

func (Dictionary) String

func (d Dictionary) String() string

type File

type File Dictionary

func (File) Extract

func (file File) Extract(output *Output, isCommand bool)

type Font

type Font struct {
	Cmap  map[int]string
	Width int
}
var FontDefault *Font = &Font{map[int]string{}, 1}

func NewFont

func NewFont(d Dictionary) *Font

func (*Font) Decode

func (font *Font) Decode(b []byte) string

type IndirectObject

type IndirectObject struct {
	Number     int
	Generation int
	Value      Object
	Stream     []byte
}

func NewIndirectObject

func NewIndirectObject(number int) *IndirectObject

func (*IndirectObject) Extract

func (object *IndirectObject) Extract(output *Output)

func (*IndirectObject) String

func (object *IndirectObject) String() string

type Keyword

type Keyword string

func NewKeyword

func NewKeyword(keyword string) Keyword

func (Keyword) String

func (keyword Keyword) String() string

type Name

type Name string

func (Name) String

func (name Name) String() string

type Number

type Number float64

func (Number) String

func (number Number) String() string

type Object

type Object interface {
	String() string
}

type Output

type Output struct {
	Commands   *os.File
	Directory  string
	Errors     *os.File
	Files      *os.File
	Javascript *os.File
	Raw        *os.File
	Text       *os.File
	URLs       *os.File
}

func NewOutput

func NewOutput(directory string) (output *Output, err error)

func (*Output) Close

func (output *Output) Close()

func (*Output) DumpFile

func (output *Output) DumpFile(name string, data []byte)

func (*Output) Error

func (output *Output) Error(message string)

type Page

type Page Dictionary

func (Page) Extract

func (page Page) Extract(output *Output)

type Parser

type Parser struct {
	*bufio.Reader

	Xref map[int]*XrefEntry
	// contains filtered or unexported fields
}

func NewParser

func NewParser(readSeeker io.ReadSeeker, output *Output) *Parser

func (*Parser) CurrentOffset

func (parser *Parser) CurrentOffset() int64

func (*Parser) GetObject

func (parser *Parser) GetObject(number int) *IndirectObject

func (*Parser) Load

func (parser *Parser) Load(password string) error

func (*Parser) ReadArray

func (parser *Parser) ReadArray(decryptor Decryptor) Array

func (*Parser) ReadCommand

func (parser *Parser) ReadCommand() (Keyword, Array, error)

func (*Parser) ReadDictionary

func (parser *Parser) ReadDictionary(decryptor Decryptor) Dictionary

func (*Parser) ReadHexString

func (parser *Parser) ReadHexString(decryptor Decryptor) String

func (*Parser) ReadInt

func (parser *Parser) ReadInt() (int, bool)

func (*Parser) ReadInt64

func (parser *Parser) ReadInt64() (int64, bool)

func (*Parser) ReadKeyword

func (parser *Parser) ReadKeyword() Keyword

func (*Parser) ReadName

func (parser *Parser) ReadName() Name

func (*Parser) ReadNumber

func (parser *Parser) ReadNumber() Number

func (*Parser) ReadObject

func (parser *Parser) ReadObject(decryptor Decryptor) (Object, error)

func (*Parser) ReadObjectHeader

func (parser *Parser) ReadObjectHeader() (int, int, bool)

ReadObjectHeader reads an object header (10 0 obj) from the current position and returns the object number and generation

func (*Parser) ReadStream

func (parser *Parser) ReadStream(decryptor Decryptor, filter_list Array, decode_parms_list Array) []byte

func (*Parser) ReadString

func (parser *Parser) ReadString(decryptor Decryptor) String

func (*Parser) Seek

func (parser *Parser) Seek(offset int64, whence int) (int64, error)

func (*Parser) SetPassword

func (parser *Parser) SetPassword(password string) error

type Reference

type Reference struct {
	Number     int
	Generation int
	// contains filtered or unexported fields
}

func NewReference

func NewReference(parser *Parser, number int, generation int) *Reference

func (*Reference) Resolve

func (reference *Reference) Resolve() Object

func (*Reference) ResolveStream

func (reference *Reference) ResolveStream() []byte

func (*Reference) String

func (reference *Reference) String() string

type SecurityHandler

type SecurityHandler struct {
	// contains filtered or unexported fields
}

func NewSecurityHandler

func NewSecurityHandler() *SecurityHandler

func (*SecurityHandler) Init

func (sh *SecurityHandler) Init(password []byte, trailer Dictionary) error

type String

type String string

func (String) String

func (s String) String() string

type XrefEntry

type XrefEntry struct {
	Offset       int64
	Generation   int
	Type         int
	IsEncrypted  bool
	IsXrefStream bool
}

func NewXrefEntry

func NewXrefEntry(offset int64, generation int, type_value int) *XrefEntry

Jump to

Keyboard shortcuts

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