CrossReferenceStream
extends PdfStream
in package
Cross-reference stream (/Type /XRef) — ISO 32000-2 §7.5.8.
A PDF 1.5+ alternative to the classic xref table. Holds xref entries as binary data inside a stream object whose dictionary also carries the trailer entries (Size, Root, Info, ID, Prev, Encrypt).
Stream entries are variable-width records described by the /W array: [type, field2, field3] Three standard entry types: 0 = free (next free obj num, generation to reuse) 1 = in use (byte offset, generation) 2 = compressed (obj num of containing ObjStm, index within stream)
Attributes
- #[RequiresPdfVersion]
- \Phpdftk\Pdf\Core\PdfVersion::V1_5
Table of Contents
Constants
- PDF_TYPE = 'XRef'
Properties
- $data : string
- $dictionary : PdfDictionary
- $encrypt : PdfReference|null
- $generationNumber : int
- $id : PdfArray|null
- $index : PdfArray|null
- $info : PdfReference|null
- $objectNumber : int
- $prev : int|null
- $root : PdfReference|null
- $size : int
- $w : PdfArray|null
Methods
- __construct() : mixed
- addCompressedEntry() : void
- Append a type-2 (compressed) entry referring to an object stream.
- addFreeEntry() : void
- Append a type-0 (free) entry.
- addInUseEntry() : void
- Append a type-1 (in-use) entry.
- packAllEntries() : void
- Auto-detect optimal /W field widths based on the maximum values in the recorded entries, then pack all entries into stream data.
- setFilter() : void
- Set a filter to encode/decode the stream data.
- toIndirectObject() : string
- Wrap the object in an indirect object structure: X Y obj ... endobj
- toPdf() : string
- Returns the stream body: dictionary, stream keyword, data, endstream.
Constants
PDF_TYPE
public
mixed
PDF_TYPE
= 'XRef'
Properties
$data
public
string
$data
= ''
$dictionary
public
PdfDictionary
$dictionary
$encrypt
public
PdfReference|null
$encrypt
= null
$generationNumber
public
int
$generationNumber
= 0
$id
public
PdfArray|null
$id
= null
$index
public
PdfArray|null
$index
= null
$info
public
PdfReference|null
$info
= null
$objectNumber
public
int
$objectNumber
= 0
$prev
public
int|null
$prev
= null
$root
public
PdfReference|null
$root
= null
$size
public
int
$size
= 0
$w
public
PdfArray|null
$w
= null
Methods
__construct()
public
__construct() : mixed
addCompressedEntry()
Append a type-2 (compressed) entry referring to an object stream.
public
addCompressedEntry(int $objStmObjNum, int $indexInStream) : void
Parameters
- $objStmObjNum : int
- $indexInStream : int
addFreeEntry()
Append a type-0 (free) entry.
public
addFreeEntry([int $nextFree = 0 ][, int $generation = 65535 ]) : void
Parameters
- $nextFree : int = 0
- $generation : int = 65535
addInUseEntry()
Append a type-1 (in-use) entry.
public
addInUseEntry(int $offset[, int $generation = 0 ]) : void
Parameters
- $offset : int
- $generation : int = 0
packAllEntries()
Auto-detect optimal /W field widths based on the maximum values in the recorded entries, then pack all entries into stream data.
public
packAllEntries() : void
Called automatically by toPdf(); can also be called manually to inspect the packed data before serialization.
setFilter()
Set a filter to encode/decode the stream data.
public
setFilter(FilterInterface $filter, string $pdfFilterName) : void
Parameters
- $filter : FilterInterface
-
The filter implementation
- $pdfFilterName : string
-
The PDF filter name (e.g. 'FlateDecode', 'ASCII85Decode')
toIndirectObject()
Wrap the object in an indirect object structure: X Y obj ... endobj
public
toIndirectObject() : string
Return values
stringtoPdf()
Returns the stream body: dictionary, stream keyword, data, endstream.
public
toPdf() : string
/Length is injected into the dictionary at serialization time. If a filter is set, the data is encoded before writing.