raw

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Array

type Array interface {
	Object
	Get(index int) (Object, bool)
	Len() int
	Append(obj Object)
}

Array represents a PDF array object.

type ArrayObj

type ArrayObj struct{ Items []Object }

Array object

func NewArray

func NewArray(items ...Object) *ArrayObj

func (*ArrayObj) Append

func (a *ArrayObj) Append(o Object)

func (*ArrayObj) Get

func (a *ArrayObj) Get(i int) (Object, bool)

func (*ArrayObj) IsIndirect

func (a *ArrayObj) IsIndirect() bool

func (*ArrayObj) Len

func (a *ArrayObj) Len() int

func (*ArrayObj) Type

func (a *ArrayObj) Type() string

type BoolObj

type BoolObj struct{ V bool }

Boolean object

func Bool

func Bool(v bool) BoolObj

func (BoolObj) IsIndirect

func (b BoolObj) IsIndirect() bool

func (BoolObj) Type

func (b BoolObj) Type() string

func (BoolObj) Value

func (b BoolObj) Value() bool

type Boolean

type Boolean interface {
	Object
	Value() bool
}

Boolean represents a PDF boolean.

type DictObj

type DictObj struct{ KV map[string]Object }

Dictionary object

func Dict

func Dict() *DictObj

func (*DictObj) Get

func (d *DictObj) Get(key Name) (Object, bool)

func (*DictObj) IsIndirect

func (d *DictObj) IsIndirect() bool

func (*DictObj) Keys

func (d *DictObj) Keys() []Name

func (*DictObj) Len

func (d *DictObj) Len() int

func (*DictObj) Set

func (d *DictObj) Set(key Name, value Object)

func (*DictObj) Type

func (d *DictObj) Type() string

type Dictionary

type Dictionary interface {
	Object
	Get(key Name) (Object, bool)
	Set(key Name, value Object)
	Keys() []Name
	Len() int
}

Dictionary represents a PDF dictionary object.

type Document

type Document struct {
	Objects           map[ObjectRef]Object
	Trailer           Dictionary
	Version           string // e.g., "1.7"
	Metadata          DocumentMetadata
	Permissions       Permissions
	MetadataEncrypted bool
	Encrypted         bool
	Linearized        bool
	HintTable         *HintTable
}

Document is the root container for raw PDF objects.

type DocumentMetadata

type DocumentMetadata struct {
	Producer string
	Creator  string
	Title    string
	Author   string
	Subject  string
	Keywords []string
}

DocumentMetadata contains common PDF info fields.

type HexStringObj

type HexStringObj struct{ Bytes []byte }

HexStringObj encodes bytes as a hexadecimal string literal.

func HexStr

func HexStr(bytes []byte) HexStringObj

func (HexStringObj) IsHex

func (s HexStringObj) IsHex() bool

func (HexStringObj) IsIndirect

func (s HexStringObj) IsIndirect() bool

func (HexStringObj) Type

func (s HexStringObj) Type() string

func (HexStringObj) Value

func (s HexStringObj) Value() []byte

type HintTable

type HintTable struct {
	PageOffsets   []PageOffsetHint
	SharedObjects []int64 // Offsets of shared objects groups
}

HintTable represents the parsed content of a linearization hint stream.

type Name

type Name interface {
	Object
	Value() string
}

Name represents a PDF name object.

type NameObj

type NameObj struct{ Val string }

Name object

func NameLiteral

func NameLiteral(v string) NameObj

Helpers

func (NameObj) IsIndirect

func (n NameObj) IsIndirect() bool

func (NameObj) Type

func (n NameObj) Type() string

func (NameObj) Value

func (n NameObj) Value() string

type Null

type Null interface{ Object }

Null represents the PDF null object.

type NullObj

type NullObj struct{}

Null object

func (NullObj) IsIndirect

func (n NullObj) IsIndirect() bool

func (NullObj) Type

func (n NullObj) Type() string

type Number

type Number interface {
	Object
	Int() int64
	Float() float64
	IsInteger() bool
}

Number represents a PDF numeric value.

type NumberObj

type NumberObj struct {
	I     int64
	F     float64
	IsInt bool
}

Number object

func NumberFloat

func NumberFloat(f float64) NumberObj

func NumberInt

func NumberInt(i int64) NumberObj

func (NumberObj) Float

func (n NumberObj) Float() float64

func (NumberObj) Int

func (n NumberObj) Int() int64

func (NumberObj) IsIndirect

func (n NumberObj) IsIndirect() bool

func (NumberObj) IsInteger

func (n NumberObj) IsInteger() bool

func (NumberObj) Type

func (n NumberObj) Type() string

type Object

type Object interface {
	Type() string
	IsIndirect() bool
}

Object is the base interface for all raw PDF objects.

type ObjectRef

type ObjectRef struct {
	Num int
	Gen int
}

ObjectRef uniquely identifies an indirect PDF object.

func (ObjectRef) String

func (r ObjectRef) String() string

type PageOffsetHint

type PageOffsetHint struct {
	MinObjNum      int
	PageLength     int64
	ContentStream  int64 // Offset
	ContentLength  int64
	SharedObjIndex int
}

type Parser

type Parser interface {
	Parse(ctx context.Context, r io.ReaderAt) (*Document, error)
}

Parser converts bytes into a raw.Document.

func NewParser

func NewParser(cfg ParserConfig) Parser

NewParser constructs a simple raw.Parser implementation.

type ParserConfig

type ParserConfig struct {
	Scanner scanner.Config
}

ParserConfig controls raw parsing behavior.

type Permissions

type Permissions struct {
	Print, Modify, Copy, ModifyAnnotations, FillForms, ExtractAccessible, Assemble, PrintHighQuality bool
}

Permissions describes allowed actions expressed in the parsed document.

type RefObj

type RefObj struct{ R ObjectRef }

Reference object

func Ref

func Ref(num, gen int) RefObj

func (RefObj) IsIndirect

func (r RefObj) IsIndirect() bool

func (RefObj) Ref

func (r RefObj) Ref() ObjectRef

func (RefObj) Type

func (r RefObj) Type() string

type Reference

type Reference interface {
	Object
	Ref() ObjectRef
}

Reference represents an indirect object reference.

type Stream

type Stream interface {
	Object
	Dictionary() Dictionary
	RawData() []byte
	Length() int64
}

Stream represents a raw (undecoded) PDF stream.

type StreamObj

type StreamObj struct {
	Dict *DictObj
	Data []byte
}

Stream object

func NewStream

func NewStream(dict *DictObj, data []byte) *StreamObj

func (*StreamObj) Dictionary

func (s *StreamObj) Dictionary() Dictionary

func (*StreamObj) IsIndirect

func (s *StreamObj) IsIndirect() bool

func (*StreamObj) Length

func (s *StreamObj) Length() int64

func (*StreamObj) RawData

func (s *StreamObj) RawData() []byte

func (*StreamObj) Type

func (s *StreamObj) Type() string

type String

type String interface {
	Object
	Value() []byte
	IsHex() bool
}

String represents a PDF string (literal or hex).

type StringObj

type StringObj struct{ Bytes []byte }

String object (literal only)

func Str

func Str(bytes []byte) StringObj

func (StringObj) IsHex

func (s StringObj) IsHex() bool

func (StringObj) IsIndirect

func (s StringObj) IsIndirect() bool

func (StringObj) Type

func (s StringObj) Type() string

func (StringObj) Value

func (s StringObj) Value() []byte

Jump to

Keyboard shortcuts

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