SetaPDF_Core_Document_Catalog_Pages Class for handling PDF pages

File: /SetaPDF/Core/Document/Catalog/Pages.php

Class hierarchy

Implements

Summary

Properties

$_annotationCache

Caches annotation object identifiers to page numbers

$_currentPagesObject

The current pages object while walking through the page tree

$_pageCount

The page count

$_pageObjects

An array holding the native indirect objects of pages

$_pageObjectsToPageNumbers

A helper array matching objects to page numbers

$_pages

An array holding page instances


Methods

__construct()

public SetaPDF_Core_Document_Catalog_Pages::__construct ( SetaPDF_Core_Document_Catalog $catalog )

The constructor.

Parameters
$catalog : SetaPDF_Core_Document_Catalog
 

_ensureAllPageObjects()

protected void SetaPDF_Core_Document_Catalog_Pages::_ensureAllPageObjects ( SetaPDF_Core_Type_IndirectObjectInterface $node )

Method to extract page objects recursively.

Parameters
$node : SetaPDF_Core_Type_IndirectObjectInterface
 

_ensureIndirectObjectAndDictionaryAndType()

private mixed SetaPDF_Core_Document_Catalog_Pages::_ensureIndirectObjectAndDictionaryAndType ( SetaPDF_Core_Type_Array $kids, integer $offset )

This method checks an entry in a Kids array for valid values and repairs it (if possible).

Parameters
$kids : SetaPDF_Core_Type_Array
 
$offset : integer
 
Exceptions

Throws SetaPDF_Core_Exception

_ensurePageObject()

protected mixed SetaPDF_Core_Document_Catalog_Pages::_ensurePageObject ( integer $pageNumber )

Ensures that a page object is read and available in the $_pageObjects property.

Parameters
$pageNumber : integer
 
Exceptions

Throws InvalidArgumentException

_readPage()

protected void SetaPDF_Core_Document_Catalog_Pages::_readPage ( integer $pageNumber )

Resolves a page object by walking forwards through the page tree.

This method is optimized, to take the fastest way through the page tree, beginning at the pages root node. The page tree will be walked forward.

Parameters
$pageNumber : integer

The original page number - 1

Exceptions

Throws SetaPDF_Core_Exception

_readPageBackwards()

protected void SetaPDF_Core_Document_Catalog_Pages::_readPageBackwards ( integer $pageNumber )

Resolves a page object by walking backwards through the page tree.

This method is optimized to take the fastest way through the page tree, beginning at the pages root node. The page tree will be walked forward.

Parameters
$pageNumber : integer
 
Exceptions

Throws SetaPDF_Core_Exception

append()

public void SetaPDF_Core_Document_Catalog_Pages::append ( SetaPDF_Core_Document_Page|SetaPDF_Core_Document_Catalog_Pages|array $pages )

Append pages to the existing pages.

Parameters
$pages : SetaPDF_Core_Document_Page|SetaPDF_Core_Document_Catalog_Pages|array
 
Exceptions

Throws SetaPDF_Core_SecHandler_Exception, InvalidArgumentException

cleanUp()

public void SetaPDF_Core_Document_Catalog_Pages::cleanUp ( void )

Release memory / cycled references.

count()

public void SetaPDF_Core_Document_Catalog_Pages::count ( void )

Returns the page count of the document.

See

create()

public SetaPDF_Core_Document_Page SetaPDF_Core_Document_Catalog_Pages::create ( string|array $format [, string $orientation = \SetaPDF_Core_PageFormats::ORIENTATION_PORTRAIT [, boolean $append = true ]] )

Create a page.

Parameters
$format : string|array

The page format. See constants in SetaPDF_Core_PageFormats and the getFormat() method.

$orientation : string

The orientation. See constants in SetaPDF_Core_PageFormats.

$append : boolean

Whether the page should be appended to the page tree or not.

deletePage()

public void SetaPDF_Core_Document_Catalog_Pages::deletePage ( integer $pageNumber )

Deletes a page.

Parameters
$pageNumber : integer
 
Exceptions

Throws SetaPDF_Core_SecHandler_Exception

ensureAllPageObjects()

public void SetaPDF_Core_Document_Catalog_Pages::ensureAllPageObjects ( void )

This method makes sure that all pages are read.

It walks the complete page tree to cache/get all page objects in one iteration. This method should be used if all pages of a document should be handled. It is much faster than using the random access.

Exceptions

Throws BadMethodCallException

extract()

public SetaPDF_Core_Document_Page|SetaPDF_Core_Type_IndirectObject SetaPDF_Core_Document_Catalog_Pages::extract ( integer $pageNumber, SetaPDF_Core_Document $document [, boolean $returnPageInstance = true ] )

Extracts a page and prepares it for the usage in another document.

This method is needed if a page should be extracted independently. For example the original document should be modified after extraction and the page itself will be edited in the new document (inherited attributes get flattened).

Parameters
$pageNumber : integer
 
$document : SetaPDF_Core_Document
 
$returnPageInstance : boolean
 

getDocument()

public SetaPDF_Core_Document SetaPDF_Core_Document_Catalog_Pages::getDocument ( void )

Get the document instance.

getLastPage()

public SetaPDF_Core_Document_Page SetaPDF_Core_Document_Catalog_Pages::getLastPage ( void )

Get the last page.

getPage()

public SetaPDF_Core_Document_Page SetaPDF_Core_Document_Catalog_Pages::getPage ( integer $pageNumber )

Get a page.

Parameters
$pageNumber : integer
 

getPageByAnnotation()

public boolean|SetaPDF_Core_Document_Page SetaPDF_Core_Document_Catalog_Pages::getPageByAnnotation ( SetaPDF_Core_Type_IndirectObject $annotationIndirectObject )

Find the page of an annotation object.

Parameters
$annotationIndirectObject : SetaPDF_Core_Type_IndirectObject
 

getPageByIndirectObject()

public SetaPDF_Core_Document_Page|false SetaPDF_Core_Document_Catalog_Pages::getPageByIndirectObject ( SetaPDF_Core_Type_IndirectObject|SetaPDF_Core_Type_IndirectReference $indirectObject )

Get a page by its indirect object.

Parameters
$indirectObject : SetaPDF_Core_Type_IndirectObject|SetaPDF_Core_Type_IndirectReference
 

getPageNumberByIndirectObject()

public boolean|integer SetaPDF_Core_Document_Catalog_Pages::getPageNumberByIndirectObject ( SetaPDF_Core_Type_IndirectObject|SetaPDF_Core_Type_IndirectReference $indirectObject )

Get the page number by a page indirect object.

If the object is not found in the page tree, false is returned.

Parameters
$indirectObject : SetaPDF_Core_Type_IndirectObject|SetaPDF_Core_Type_IndirectReference
 
Exceptions

Throws InvalidArgumentException

getPageNumberByPageObject()

public boolean|integer SetaPDF_Core_Document_Catalog_Pages::getPageNumberByPageObject ( SetaPDF_Core_Document_Page $page )

Get the page number by a page object.

If the object is not found in the page tree, false is returned.

Parameters
$page : SetaPDF_Core_Document_Page
 

getPagesIndirectObject()

public SetaPDF_Core_Type_IndirectObject SetaPDF_Core_Document_Catalog_Pages::getPagesIndirectObject ( integer $pageNumber )

Get a pages indirect object.

Parameters
$pageNumber : integer
 

prepend()

resolvePagesRootObject()

public SetaPDF_Core_Type_IndirectObject SetaPDF_Core_Document_Catalog_Pages::resolvePagesRootObject ( [ boolean $create = false ] )

Resolves the root page tree node.

Parameters
$create : boolean