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 ¶
- func IsDelimiter(c byte) bool
- func IsNameChar(c byte) bool
- func IsSpace(c byte) bool
- func KeyIndex(content []byte, key string) int
- func ParseLiteral(data []byte, start int) (string, int)
- func RemoveDictEntry(dictionary []byte, key string) []byte
- func SkipArray(data []byte, start int) (int, bool)
- func SkipBalanced(data []byte, start int, open, closing []byte) int
- func SkipIndirectRef(data []byte, start int) (int, bool)
- func SkipLiteral(data []byte, start int) int
- func SkipSpaces(data []byte, start int) int
- func SkipToken(data []byte, start int) int
- func SkipValue(data []byte, start int) int
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsDelimiter ¶
IsDelimiter reports whether c is a PDF delimiter (PDF 32000-1 §7.2.2).
func IsNameChar ¶
IsNameChar reports whether c can appear in a PDF name after the leading '/'.
func KeyIndex ¶
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 ¶
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 ¶
RemoveDictEntry drops the "/key value" pair from a dictionary body, returning the dictionary unchanged when the key is absent.
func SkipArray ¶
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 ¶
SkipBalanced consumes a construct delimited by the multi-byte open/closing markers (typically "<<" and ">>"), honouring nesting and literal strings.
func SkipIndirectRef ¶
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 ¶
SkipLiteral consumes a literal string "(…)", honouring nested parentheses and backslash escapes.
func SkipSpaces ¶
SkipSpaces returns the offset of the first non-whitespace byte at or after start.
Types ¶
This section is empty.