phpdftk API Documentation

CrossReferenceTable
in package

Builds the classic PDF cross-reference table (ISO 32000-2 section 7.5.4).

The fixed 20-byte entry width is mandated by the spec so that readers can seek directly to any entry by index without parsing the entire table:

OOOOOOOOOO GGGGG n \r\n (in-use object: O = 10-digit byte offset) OOOOOOOOOO GGGGG f \r\n (free object: O = next free object number)

Object 0 is always emitted as the free-list head with generation 65535, which signals that it can never be reused.

Table of Contents

Methods

add()  : void
Record the byte offset for an in-use object.
build()  : string
Build and return the complete xref section as a string.
getEntries()  : array<int, int>
Return recorded entries (objectNumber => byte offset).

Methods

add()

Record the byte offset for an in-use object.

public add(int $objNum, int $offset) : void
Parameters
$objNum : int
$offset : int

build()

Build and return the complete xref section as a string.

public build(int $size) : string

The returned string starts with "xref\n" and ends with the last entry (no trailing newline).

Parameters
$size : int
Return values
string

getEntries()

Return recorded entries (objectNumber => byte offset).

public getEntries() : array<int, int>
Return values
array<int, int>

        
On this page

Search results