pdfscan

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: MIT Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package pdfscan holds a minimal byte scanner for the subset of PDF syntax that paper's reader, form filler and signer need in order to walk object dictionaries in place, without building a full object model.

Every Skip* function takes the byte offset to start at and returns the offset just past the construct it consumed. Malformed input never panics: scanning runs to the end of data and returns len(data).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsDelimiter

func IsDelimiter(c byte) bool

IsDelimiter reports whether c is a PDF delimiter (PDF 32000-1 §7.2.2).

func IsNameChar

func IsNameChar(c byte) bool

IsNameChar reports whether c can appear in a PDF name after the leading '/'.

func IsSpace

func IsSpace(c byte) bool

IsSpace reports whether c is PDF whitespace (PDF 32000-1 §7.2.2).

func KeyIndex

func KeyIndex(content []byte, key string) int

KeyIndex returns the offset of the "/key" entry in a dictionary, or -1 when absent. Longer names that merely start with key (e.g. "/Type" for "/Ty") are skipped.

func ParseLiteral

func ParseLiteral(data []byte, start int) (string, int)

ParseLiteral consumes a literal string "(…)" and returns its contents with the outer parentheses removed and each backslash escape reduced to the byte that follows it.

func RemoveDictEntry

func RemoveDictEntry(dictionary []byte, key string) []byte

RemoveDictEntry drops the "/key value" pair from a dictionary body, returning the dictionary unchanged when the key is absent.

func SkipArray

func SkipArray(data []byte, start int) (int, bool)

SkipArray consumes an array "[…]", honouring nesting and literal strings. It returns the index just past the array and reports whether the closing bracket was found. Callers that slice the array's interior must check: an unterminated array ends at len(data), and the interior bounds [start+1 : end-1] are then invalid for a trailing "[".

func SkipBalanced

func SkipBalanced(data []byte, start int, open, closing []byte) int

SkipBalanced consumes a construct delimited by the multi-byte open/closing markers (typically "<<" and ">>"), honouring nesting and literal strings.

func SkipIndirectRef

func SkipIndirectRef(data []byte, start int) (int, bool)

SkipIndirectRef consumes an indirect reference ("12 0 R"). It reports false and leaves the offset untouched when the bytes at start are something else.

func SkipLiteral

func SkipLiteral(data []byte, start int) int

SkipLiteral consumes a literal string "(…)", honouring nested parentheses and backslash escapes.

func SkipSpaces

func SkipSpaces(data []byte, start int) int

SkipSpaces returns the offset of the first non-whitespace byte at or after start.

func SkipToken

func SkipToken(data []byte, start int) int

SkipToken consumes one regular token (a name, number or keyword). A single delimiter byte counts as a token so callers always make progress.

func SkipValue

func SkipValue(data []byte, start int) int

SkipValue consumes one PDF value: a dictionary, indirect reference, array, literal string or bare token.

Types

This section is empty.

Jump to

Keyboard shortcuts

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