setasign\SetaPDF2\Core\Document

Page Class representing a PDF page

File: /SetaPDF v2/Core/Document/Page.php
Old class name (alias): \SetaPDF_Core_Document_Page

Class hierarchy

Implements

Summary

Properties

$_additionalActions

The additional actions object of this page

$_annotations

The annotations object

$_canvas

The canvas object of this page

$_contents

The contents object for this page

$_inheritedAttributes

protected array Page::$_inheritedAttributes = array()

Inherited attributes

An array of \setasign\SetaPDF2\Core\Type\Dictionary\Entry instances

$_inheritedAttributesResolved

protected bool Page::$_inheritedAttributesResolved = false

Flag for resolving of inherited attributes

$_pageIsObserved

protected bool Page::$_pageIsObserved = false

Flag for observing the page object

$_pageObject

The page indirect object


Static Methods

create()

public static Page::create (
\SetaPDF_Core_Document $document,
array|\SetaPDF_Core_Type_Dictionary $values = array ( )
): \SetaPDF_Core_Document_Page

Creates a new page for a specific document.

Parameters
$document : \SetaPDF_Core_Document
 
$values : array|\SetaPDF_Core_Type_Dictionary
 
Exceptions

Throws \setasign\SetaPDF2\Core\Exception


Methods

__construct()

The constructor.

Parameters
$pageObject : \SetaPDF_Core_Type_IndirectObject
 
Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

_checkBoundary()

Checks a boundary for validity.

Parameters
$newBoundary : \SetaPDF_Core_DataStructure_Rectangle|\SetaPDF_Core_Type_Array
 
$newBox : string
 
Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

Throws \OutOfBoundsException

_ensureInheritedAttributes()

protected Page::_ensureInheritedAttributes (
void
): void

Ensures that all inherited properties are resolved.

Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

_ensureObservation()

protected Page::_ensureObservation (
void
): void

Make sure that the page object is observed.

_getBoundary()

Get a page boundary box of the page (wihtout logic for invalid values).

Parameters
$box : string

See \setasign\SetaPDF2\Core\PageBoundaries::XXX_BOX constants

$fallback : bool

Use the fallback box instead if box not exist

$asRect : bool

Return boundary box as \setasign\SetaPDF2\Core\DataStructure\Rectangle

Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

See

cleanUp()

public Page::cleanUp (
void
): void

Release memory/resources.

flattenInheritedAttributes()

public Page::flattenInheritedAttributes (
void
): void

Flattens the inherited attributes to the main page object.

Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

getAdditionalActions()

Gets the additional actions object instance for this page.

getAnnotations()

Gets the annotation instance of this page.

getArtBox()

public Page::getArtBox (
bool $fallback = true,
bool $asRect = true
): bool|\SetaPDF_Core_DataStructure_Rectangle|\SetaPDF_Core_Type_Array

Get the art box of this page.

Parameters
$fallback : bool
 
$asRect : bool
 
Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

getAttribute()

public Page::getAttribute (
string $name,
bool $inherited = true
): ?\SetaPDF_Core_Type_AbstractType

Get an attribute of the page object or from an inherited pages object.

Parameters
$name : string
 
$inherited : bool
 
Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

getBleedBox()

public Page::getBleedBox (
bool $fallback = true,
bool $asRect = true
): bool|\SetaPDF_Core_DataStructure_Rectangle|\SetaPDF_Core_Type_Array

Get the bleed box of this page.

Parameters
$fallback : bool
 
$asRect : bool
 
Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

getBoundary()

Get a page boundary box of the page.

To work with the boundary box it should be cloned and reset by the Page::setBoundary() method. This is necessary because a box could be inherited by a parent page tree node.

Parameters
$box : string

See \setasign\SetaPDF2\Core\PageBoundaries::XXX_BOX constants

$fallback : bool

Use the fallback box instead if box not exist

$asRect : bool

Return boundary box as \setasign\SetaPDF2\Core\DataStructure\Rectangle

Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

getCanvas()

Gets the canvas instance for this page.

getContents()

Gets the contents instance of this page.

getCropBox()

public Page::getCropBox (
bool $fallback = true,
bool $asRect = true
): bool|\SetaPDF_Core_DataStructure_Rectangle|\SetaPDF_Core_Type_Array

Get the crop box of this page.

Parameters
$fallback : bool
 
$asRect : bool
 
Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

getDictionary()

Get the page dictionary.

Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

getGroup()

Get a group attributes object.

Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

getHeight()

public Page::getHeight (
string $box = \setasign\SetaPDF2\Core\PageBoundaries::CROP_BOX,
bool $fallback = true
): float|int|bool

Get the height of the page.

Parameters
$box : string
 
$fallback : bool
 
Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

getLastModified()

public Page::getLastModified (
bool $asString = true
): null|string|\SetaPDF_Core_DataStructure_Date

Get the date and time the page was edited.

Parameters
$asString : bool
 
Exceptions

Throws \Exception

getMediaBox()

public Page::getMediaBox (
bool $fallback = true,
bool $asRect = true
): bool|\SetaPDF_Core_DataStructure_Rectangle|\SetaPDF_Core_Type_Array

Get the media box of this page.

Parameters
$fallback : bool
 
$asRect : bool
 
Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

getMetadata()

public Page::getMetadata (
void
): ?string

Get the metadata stream of a page.

This is a method for low level access to the XMP stream data of a page.

Return Values

Null if no metadata are available.
A string if the desired structure is available.

Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

getObject()

public Page::getObject (
bool $observe = false
): \SetaPDF_Core_Type_IndirectObject

Get the page object.

Parameters
$observe : bool
 

getOrientation()

public Page::getOrientation (
string $box = \setasign\SetaPDF2\Core\PageBoundaries::CROP_BOX,
bool $fallback = true
): bool|string

Get the orientation of the page.

Parameters
$box : string

See \setasign\SetaPDF2\Core\PageBoundaries::XXX_BOX constants

$fallback : bool

Use the fallback box instead if box not exist

Return Values

false or one of \setasign\SetaPDF2\Core\PageFormats::ORIENTATION_XXX constants

Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

getPageObject()

public Page::getPageObject (
bool $observe = false
): \SetaPDF_Core_Type_IndirectObject

Get the page indirect object.

Parameters
$observe : bool
 

getRotation()

public Page::getRotation (
void
): int

Get the page rotation.

getStreamProxy()

Get the pages stream proxy object.

getTrimBox()

public Page::getTrimBox (
bool $fallback = true,
bool $asRect = true
): bool|\SetaPDF_Core_DataStructure_Rectangle|\SetaPDF_Core_Type_Array

Get the trim box of this page.

Parameters
$fallback : bool
 
$asRect : bool
 
Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

getWidth()

public Page::getWidth (
string $box = \setasign\SetaPDF2\Core\PageBoundaries::CROP_BOX,
bool $fallback = true
): float|int|bool

Get the width of the page.

Parameters
$box : string
 
$fallback : bool
 
Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

getWidthAndHeight()

public Page::getWidthAndHeight (
string $box = \setasign\SetaPDF2\Core\PageBoundaries::CROP_BOX,
bool $fallback = true
): array|bool

Get width and height of the page.

Parameters
$box : string
 
$fallback : bool
 
Return Values

array(width, height)

Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

rotateBy()

public Page::rotateBy (
int $rotation
): \SetaPDF_Core_Document_Page

Rotate a page by degrees.

Parameters
$rotation : int

Degrees to rotate by

Return Values

Returns the Page object for method chaining.

Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

setBleedBox()

Set the bleed box.

Parameters
$boundary : array|\SetaPDF_Core_Type_Dictionary_Entry|\SetaPDF_Core_Type_Array|\SetaPDF_Core_DataStructure_Rectangle
 
$checkBoundary : bool

Ensure that boundary values are valid or not

Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

setBoundary()

Set a boundary box.

A boundary consists of four numeric values: llx, lly, urx and ury. They can be passed in various ways:

Parameters
$boundary : array|\SetaPDF_Core_Type_Dictionary_Entry|\SetaPDF_Core_Type_Array|\SetaPDF_Core_DataStructure_Rectangle
 
$box : string

The page boundary name

$checkBoundary : bool

Ensure that boundary values are valid or not

Exceptions

Throws \InvalidArgumentException

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

setCropBox()

Set the crop box.

Parameters
$boundary : array|\SetaPDF_Core_Type_Dictionary_Entry|\SetaPDF_Core_Type_Array|\SetaPDF_Core_DataStructure_Rectangle
 
$checkBoundary : bool

Ensure that boundary values are valid or not

Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

setGroup()

public Page::setGroup (): void

Set the group attributes object.

Parameters
$group : false|\SetaPDF_Core_TransparencyGroup
 
Exceptions

Throws \InvalidArgumentException

Throws \setasign\SetaPDF2\Core\Type\Exception

setLastModified()

Set the date and time the page was edited.

Parameters
$date : string|\SetaPDF_Core_DataStructure_Date

The last modification date. An instance of \setasign\SetaPDF2\Core\DataStructure\Date. Alternatively a string which is passed to its constructor.

Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

Throws \Exception

setMediaBox()

Set the media box.

Parameters
$boundary : array|\SetaPDF_Core_Type_Dictionary_Entry|\SetaPDF_Core_Type_Array|\SetaPDF_Core_DataStructure_Rectangle
 
$checkBoundary : bool

Ensure that boundary values are valid or not

Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

setMetadata()

public Page::setMetadata (
string $metadata
): void

Set the metadata stream.

To remove the metadata just pass null to this method.

Parameters
$metadata : string
 
Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

setRotation()

public Page::setRotation (
int $rotation
): \SetaPDF_Core_Document_Page

Set the page rotation.

Parameters
$rotation : int

The rotation value

Return Values

Returns the Page object for method chaining.

Exceptions

Throws \InvalidArgumentException

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

setTrimBox()

Set the trim box.

Parameters
$boundary : array|\SetaPDF_Core_Type_Dictionary_Entry|\SetaPDF_Core_Type_Array|\SetaPDF_Core_DataStructure_Rectangle
 
$checkBoundary : bool

Ensure that boundary values are valid or not

Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

toXObject()

Converts the page object into a form XObject.

Parameters
$document : \SetaPDF_Core_Document
 
$box : string

The name of the bounding box

Exceptions

Throws \setasign\SetaPDF2\NotImplementedException

Throws \setasign\SetaPDF2\Core\Type\Exception