SetaPDF_Core_Parser_CrossReferenceTable A PDF cross reference parser

File: /SetaPDF v2/Core/Parser/CrossReferenceTable.php

Class hierarchy

Implements

Summary

Constants

COMPRESSED_ALL

const integer SetaPDF_Core_Parser_CrossReferenceTable::COMPRESSED_ALL = 1

Constant for full compression.

COMPRESSED_HYBRID

const integer SetaPDF_Core_Parser_CrossReferenceTable::COMPRESSED_HYBRID = 2

Constant for a hybrid compression.

COMPRESSED_NONE

const integer SetaPDF_Core_Parser_CrossReferenceTable::COMPRESSED_NONE = 0

Constant for none compression.


Static Properties

$fileTrailerSearchLength

static public integer SetaPDF_Core_Parser_CrossReferenceTable::$fileTrailerSearchLength = 5500

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

$readOnAccess

static public boolean SetaPDF_Core_Parser_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 an 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

protected integer SetaPDF_Core_Parser_CrossReferenceTable::$_compressed = 0

Cross reference uses compressed object streams, hybrid or none

$_compressedXrefObjects

protected array SetaPDF_Core_Parser_CrossReferenceTable::$_compressedXrefObjects = array()

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

$_maxObjId

protected integer SetaPDF_Core_Parser_CrossReferenceTable::$_maxObjId = 0

The greatest used object id

$_objectOffsets

protected array SetaPDF_Core_Parser_CrossReferenceTable::$_objectOffsets = array(...)

The cross reference content

$_parser

protected SetaPDF_Core_Parser_Pdf SetaPDF_Core_Parser_CrossReferenceTable::$_parser

The PDF parser instance

$_parserObjectOffsets

protected array SetaPDF_Core_Parser_CrossReferenceTable::$_parserObjectOffsets = array()

Object offsets in the parser File

$_pointerToXref

protected integer SetaPDF_Core_Parser_CrossReferenceTable::$_pointerToXref

The initial pointer to the xref table

$_startOffset

protected int SetaPDF_Core_Parser_CrossReferenceTable::$_startOffset

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

$_trailer

protected SetaPDF_Core_Type_Dictionary SetaPDF_Core_Parser_CrossReferenceTable::$_trailer

The trailer dictionary

$_updatedOffsets

protected array SetaPDF_Core_Parser_CrossReferenceTable::$_updatedOffsets = array()

Updated offsets

$_xrefSubsection

protected array SetaPDF_Core_Parser_CrossReferenceTable::$_xrefSubsection = array()

Offset positions of subsections or cross reference stream objects


Methods

__construct()

_findStartOffset()

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 SetaPDF_Core_Parser_CrossReferenceTable_Exception

See

_readTrailerAndXref()

protected SetaPDF_Core_Parser_CrossReferenceTable::_readTrailerAndXref (
integer|boolean $xrefOffset
): void

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

Parameters
$xrefOffset : integer|boolean
 
Exceptions

Throws SetaPDF_Core_Parser_CrossReferenceTable_Exception

_readXref()

Read the xref table at a specific position.

Exceptions

Throws SetaPDF_Core_Parser_CrossReferenceTable_Exception

cleanUp()

Release memory/references.

deleteObject()

public SetaPDF_Core_Document_CrossReferenceTable::deleteObject (
integer $objectId
): void

Mark an object as deleted.

Parameters
$objectId : integer
 

getCompressedStream()

public SetaPDF_Core_Document_CrossReferenceTable::getCompressedStream (
SetaPDF_Core_Type_Dictionary $value, integer $newPointerToXref [, boolean $onlyUpdated = true ]
): boolean|SetaPDF_Core_Type_Stream

Get the cross reference as a compressed stream object.

Parameters
$value : SetaPDF_Core_Type_Dictionary
 
$newPointerToXref : integer
 
$onlyUpdated : boolean
 

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()

Alias for getDefinedObjectIds()

getGenerationNumberByObjectId()

public SetaPDF_Core_Parser_CrossReferenceTable::getGenerationNumberByObjectId (
integer $objectId
): integer|boolean

Get the generation number by an object id.

Parameters
$objectId : integer
 

getOffsetFor()

public SetaPDF_Core_Document_CrossReferenceTable::getOffsetFor (
integer $objectId [, integer|null $generation = 0 ]
): integer|array|boolean

Get an offset for an object.

Parameters
$objectId : integer
 
$generation : integer|null
 

getParserOffsetFor()

public SetaPDF_Core_Parser_CrossReferenceTable::getParserOffsetFor (
integer $objectId [, integer $generation = null [, integer &$objectGeneration = null ]]
): boolean|mixed

Returns the offset position of an object.

Parameters
$objectId : integer
 
$generation : integer
 
$objectGeneration : integer

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

getPointerToXref()

Find the initial point to the xref table.

Exceptions

Throws SetaPDF_Core_Parser_CrossReferenceTable_Exception

getSize()

Get the size of the cross reference table.

getStartOffset()

Get the start offset.

getTrailer()

isCompressed()

Check if the xref table uses compressed xref streams.

Use getCompressed

isOffsetUpdated()

public SetaPDF_Core_Document_CrossReferenceTable::isOffsetUpdated (
integer $objectId
): boolean

Checks if an objects offset is updated.

Parameters
$objectId : integer
 

setOffsetFor()

public SetaPDF_Core_Document_CrossReferenceTable::setOffsetFor (
integer $objectId, integer $generation, integer|array $offset
): void

Set an object offset.

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

updateSize()

public SetaPDF_Core_Document_CrossReferenceTable::updateSize (
integer $objectId
): void

Updates the size value of this cross-reference table.

Parameters
$objectId : integer
 

writeNormal()

public SetaPDF_Core_Document_CrossReferenceTable::writeNormal (
SetaPDF_Core_Writer_WriterInterface $writer [, boolean $onlyUpdated = true ]
): integer

Writes the cross reference to a writer.

Parameters
$writer : SetaPDF_Core_Writer_WriterInterface
 
$onlyUpdated : boolean