contentstream

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package contentstream provides parsing of PDF content streams.

Content streams contain the instructions for rendering page content, including text display, graphics operations, and image placement.

Content Stream Operations

PDF content streams consist of operators and their operands:

parser := contentstream.NewParser(streamData)
ops, err := parser.Parse()
for _, op := range ops {
    fmt.Printf("Operator: %s, Operands: %v\n", op.Operator, op.Operands)
}

Common Operators

Text operators:

  • BT, ET - Begin/end text object
  • Tf - Set font and size
  • Tm - Set text matrix
  • Tj, TJ - Show text
  • Td, TD - Move text position

Graphics state operators:

  • q, Q - Save/restore graphics state
  • cm - Modify CTM (current transformation matrix)
  • w - Set line width
  • J, j - Set line cap/join style

Path operators:

  • m, l - Move to, line to
  • re - Rectangle
  • S, s, f, f* - Stroke and fill paths

Operand Types

Operands can be any PDF object type:

  • Numbers (core.Int, core.Real)
  • Strings (core.String)
  • Names (core.Name)
  • Arrays (core.Array)
  • Dictionaries (core.Dict)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Operation

type Operation struct {
	Operator string        // The operator (e.g., "Tj", "Tm", "q")
	Operands []core.Object // The operands
}

Operation represents a single content stream operation consisting of an operator and its operands. Operands are PDF objects that precede the operator.

type Parser

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

Parser parses PDF content streams into a sequence of operations. Each operation consists of an operator and its operands.

func NewParser

func NewParser(data []byte) *Parser

NewParser creates a new content stream parser for the given data.

func (*Parser) Parse

func (p *Parser) Parse() ([]Operation, error)

Parse parses the content stream and returns all operations in order.

Jump to

Keyboard shortcuts

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