setasign\SetaPDF2\Core\Parser\CrossReferenceTable

CrossReferenceTable A PDF cross reference parser

File: /SetaPDF v2/Core/Parser/CrossReferenceTable/CrossReferenceTable.php
Old class name (alias): \SetaPDF_Core_Parser_CrossReferenceTable

Class hierarchy

Implements

Summary

Constants

COMPRESSED_ALL

public const int CrossReferenceTable::COMPRESSED_ALL = 1

Constant for full compression.

COMPRESSED_HYBRID

Constant for a hybrid compression.

COMPRESSED_NONE

public const int CrossReferenceTable::COMPRESSED_NONE = 0

Constant for none compression.


Static Properties

$fileTrailerSearchLength

The byte count in which the initial xref keyword should be searched for

$readOnAccess

static public bool CrossReferenceTable::$readOnAccess = true

A flag indicating the way of reading the xref table.

If set to true, the xref table will only read/resolved if the access to an object is needed. This is very fast for a small amount of access (updates). If set to false, the complete xref-table will be read in at once. This is faster if the document should be completely rewritten.


Properties

$_compressed

Cross-reference uses compressed object streams, hybrid or none

$_compressedXrefObjects

protected array CrossReferenceTable::$_compressedXrefObjects = array()

An array holding all resolved indirect objects representing compressed xref tables.

$_compressedXrefObjectsOffsets

Object offsets of cross-reference streams.

We separate these offsets to allow faulty overwrites of these objects.

$_maxObjId

The greatest used object id

$_objectOffsets

The cross-reference content

$_parser

The PDF parser instance

$_parserObjectOffsets

protected array CrossReferenceTable::$_parserObjectOffsets = array()

Object offsets in the parser File

$_pointerToXref

The initial pointer to the xref table

$_startOffset

Offset for PDF documents with invalid data before the PDF header.

$_trailer

The trailer dictionary

$_updatedOffsets

$_xrefSubsection

protected array CrossReferenceTable::$_xrefSubsection = array()

Offset positions of subsections or cross reference stream objects


Methods

_findStartOffset()

protected CrossReferenceTable::_findStartOffset (
void
): void

Counts the bytes to the initial PDF file header to get an offset which will be used along with all other byte offsets.

Exceptions

Throws Exception

See

_readTrailerAndXref()

protected CrossReferenceTable::_readTrailerAndXref (
int|bool $xrefOffset
): void

Read the document trailer and initiate the initial parsing of the xref table.

Parameters
$xrefOffset : int|bool
 
Exceptions

Throws \setasign\SetaPDF2\Core\Exception

Throws Exception

Throws \setasign\SetaPDF2\Core\Parser\Pdf\InvalidTokenException

Throws \setasign\SetaPDF2\Core\Type\IndirectReference\Exception

_readXref()

protected CrossReferenceTable::_readXref (
void
): void

Read the xref table at a specific position.

Exceptions

Throws Exception

cleanUp()

public CrossReferenceTable::cleanUp (
void
): void

Release memory/references.

deleteObject()

Mark an object as deleted.

Parameters
$objectId : int
 

getCompressedStream()

Get the cross-reference as a compressed stream object.

Parameters
$value : \SetaPDF_Core_Type_Dictionary
 
$newPointerToXref : int
 
$onlyUpdated : bool
 

getCompressedXrefObjects()

Get all indirect objects holding cross-reference streams.

getDefinedObjectIds()

Get all defined object ids.

This method returns an array of all objects which are noticed in any cross-reference table. The appearance of an object id in this list is not an evidence of existence of the desired object.

getDefiniedObjectIds()

WARNING: This method is marked as deprecated!

Alias for getDefinedObjectIds()

getGenerationNumberByObjectId()

public CrossReferenceTable::getGenerationNumberByObjectId (
int $objectId
): int|bool

Get the generation number by an object id.

Parameters
$objectId : int
 
Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

getOffsetFor()

public \setasign\SetaPDF2\Core\Document\CrossReferenceTable::getOffsetFor (
int $objectId,
?int $generation = 0
): int|array|bool

Get an offset for an object.

Parameters
$objectId : int
 
$generation : ?int
 

getParserOffsetFor()

public CrossReferenceTable::getParserOffsetFor (
int $objectId,
int $generation = null,
int &$objectGeneration = null
): false|array

Returns the offset position of an object.

Parameters
$objectId : int
 
$generation : int
 
$objectGeneration : int

The final generation number, resolved if no generation number was given.

Exceptions

Throws \setasign\SetaPDF2\Core\Parser\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

Throws \setasign\SetaPDF2\Exception

Throws \setasign\SetaPDF2\NotImplementedException

getParserOffsetOfCrossreferenceStream()

public CrossReferenceTable::getParserOffsetOfCrossreferenceStream (
int $objectId,
int $generation
): false|mixed

Get the byte-offset of a cross-reference stream by its object id.

Parameters
$objectId : int
 
$generation : int
 

getPointerToXref()

Find the initial point to the xref table.

Exceptions

Throws \setasign\SetaPDF2\Core\Exception

Throws Exception

Throws \setasign\SetaPDF2\Core\Type\IndirectReference\Exception

getSize()

Get the size of the cross-reference table.

getStartOffset()

public CrossReferenceTable::getStartOffset (
void
): int

Get the start offset.

getTrailer()

Returns the trailer dictionary.

isCompressed()

public CrossReferenceTable::isCompressed (
void
): int

Check if the xref table uses compressed xref streams.

Use getCompressed

isOffsetUpdated()

Checks if an objects offset is updated.

Parameters
$objectId : int
 

offsetsUpdated()

Checks whether any offset was updated or not.

setOffsetFor()

public \setasign\SetaPDF2\Core\Document\CrossReferenceTable::setOffsetFor (
int $objectId,
int $generation,
int|array $offset
): void

Set an object offset.

Parameters
$objectId : int
 
$generation : int
 
$offset : int|array
 

updateSize()

Updates the size value of this cross-reference table.

Parameters
$objectId : int
 

writeNormal()

Writes the cross-reference to a writer.

Parameters
$writer : \SetaPDF_Core_Writer_WriterInterface
 
$onlyUpdated : bool