objects

package
v0.0.0-...-4d6acc0 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EscapeString

func EscapeString(s string) string

Types

type Array

type Array []Object

Array is a PDF array object.

func (Array) String

func (a Array) String() string

func (Array) WriteEncrypted

func (a Array) WriteEncrypted(w io.Writer, ec *EncryptionContext, objNum, objGen int) (int64, error)

func (Array) WriteTo

func (a Array) WriteTo(w io.Writer) (int64, error)

type Boolean

type Boolean bool

Boolean represents a PDF boolean object (true or false).

func (Boolean) String

func (b Boolean) String() string

func (Boolean) WriteEncrypted

func (b Boolean) WriteEncrypted(w io.Writer, ec *EncryptionContext, objNum, objGen int) (int64, error)

func (Boolean) WriteTo

func (b Boolean) WriteTo(w io.Writer) (int64, error)

type Dictionary

type Dictionary map[string]Object

Dictionary is a PDF dictionary object.

func (Dictionary) String

func (d Dictionary) String() string

func (Dictionary) WriteEncrypted

func (d Dictionary) WriteEncrypted(w io.Writer, ec *EncryptionContext, objNum, objGen int) (int64, error)

func (Dictionary) WriteTo

func (d Dictionary) WriteTo(w io.Writer) (int64, error)

type EncryptionContext

type EncryptionContext struct {
	O          []byte // Owner key
	U          []byte // User key
	P          int32  // Permissions
	FileID     []byte // ID from trailer
	EncryptKey []byte // Global encryption key
	Algorithm  int    // 1 (RC4), 2 (RC4 128), 4 (AES 128), 5 (AES 256)
	Revision   int    // 2 (40-bit), 3 (128-bit), 4 (Acrobat 7), 5 (Acrobat 9), 6 (Acrobat X)
}

EncryptionContext holds keys and data for PDF encryption.

func NewEncryptionContext

func NewEncryptionContext(password string, fileID []byte) *EncryptionContext

NewEncryptionContext creates a new EncryptionContext from a password and file ID.

func (*EncryptionContext) Encrypt

func (ec *EncryptionContext) Encrypt(data []byte, objNum, objGen int) []byte

Encrypt encrypts data using the object's ID and generation.

func (*EncryptionContext) WriteEncrypted

func (ec *EncryptionContext) WriteEncrypted(w io.Writer, data []byte, objNum, objGen int) (int64, error)

WriteEncrypted writes data as a hex string or literal string, encrypted if necessary.

type Float

type Float float64

Float represents a PDF real number object.

func (Float) String

func (f Float) String() string

func (Float) WriteEncrypted

func (f Float) WriteEncrypted(w io.Writer, ec *EncryptionContext, objNum, objGen int) (int64, error)

func (Float) WriteTo

func (f Float) WriteTo(w io.Writer) (int64, error)

type IndirectObject

type IndirectObject struct {
	Number     int
	Generation int
	Data       Object
}

IndirectObject is a PDF indirect object.

func (*IndirectObject) String

func (io *IndirectObject) String() string

func (*IndirectObject) WriteEncrypted

func (io *IndirectObject) WriteEncrypted(w io.Writer, ec *EncryptionContext, objNum, objGen int) (int64, error)

func (*IndirectObject) WriteTo

func (io *IndirectObject) WriteTo(w io.Writer) (int64, error)

type Integer

type Integer int

Integer is a PDF integer object.

func (Integer) String

func (i Integer) String() string

func (Integer) WriteEncrypted

func (i Integer) WriteEncrypted(w io.Writer, ec *EncryptionContext, objNum, objGen int) (int64, error)

func (Integer) WriteTo

func (i Integer) WriteTo(w io.Writer) (int64, error)

type Name

type Name string

Name represents a PDF name object.

func (Name) String

func (n Name) String() string

String returns the name in PDF format (starting with /).

func (Name) WriteEncrypted

func (n Name) WriteEncrypted(w io.Writer, ec *EncryptionContext, objNum, objGen int) (int64, error)

func (Name) WriteTo

func (n Name) WriteTo(w io.Writer) (int64, error)

type Object

type Object interface {
	// String returns the PDF representation of the object.
	String() string
	// WriteTo writes the PDF representation to the writer.
	WriteTo(w io.Writer) (int64, error)
	// WriteEncrypted writes the PDF representation to the writer, encrypted if needed.
	WriteEncrypted(w io.Writer, ec *EncryptionContext, objNum, objGen int) (int64, error)
}

Object is the base interface for all PDF objects. Primitives include Name, Integer, String, Array, and Dictionary.

type ObjectManager

type ObjectManager struct {
	Objects []IndirectObject
	// contains filtered or unexported fields
}

ObjectManager handles PDF objects and their generation.

func NewObjectManager

func NewObjectManager() *ObjectManager

NewObjectManager creates a new ObjectManager.

func (*ObjectManager) AddObject

func (m *ObjectManager) AddObject(obj Object) Reference

AddObject adds an object and returns its reference.

func (*ObjectManager) Write

func (m *ObjectManager) Write(w io.Writer, catalogRef Reference, infoRef *Reference, ec *EncryptionContext, encryptRef *Reference, fileID []byte) error

Write writes the PDF to the writer.

type PDFString

type PDFString string

PDFString is a PDF literal string object. Renamed from String to avoid conflict with string type.

func (PDFString) String

func (s PDFString) String() string

func (PDFString) WriteEncrypted

func (s PDFString) WriteEncrypted(w io.Writer, ec *EncryptionContext, objNum, objGen int) (int64, error)

func (PDFString) WriteTo

func (s PDFString) WriteTo(w io.Writer) (int64, error)

type Reference

type Reference struct {
	Number     int
	Generation int
}

Reference is a PDF reference object.

func (Reference) String

func (r Reference) String() string

func (Reference) WriteEncrypted

func (r Reference) WriteEncrypted(w io.Writer, ec *EncryptionContext, objNum, objGen int) (int64, error)

func (Reference) WriteTo

func (r Reference) WriteTo(w io.Writer) (int64, error)

type Stream

type Stream struct {
	Dict Dictionary
	Data []byte
}

Stream represents a PDF stream object.

func (Stream) String

func (s Stream) String() string

func (Stream) WriteEncrypted

func (s Stream) WriteEncrypted(w io.Writer, ec *EncryptionContext, objNum, objGen int) (int64, error)

func (Stream) WriteTo

func (s Stream) WriteTo(w io.Writer) (int64, error)

Jump to

Keyboard shortcuts

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