SetaPDF_Core_Document_OutlinesItem Class representing an outline item

File: /SetaPDF v2/Core/Document/OutlinesItem.php

Class hierarchy

Implements

Summary

Constants

ACTION

public const string SetaPDF_Core_Document_OutlinesItem::ACTION = 'action'

Configuration key

APPEND_MODE_COPY

Append mode value

APPEND_MODE_MOVE

Append mode value

APPEND_MODE_NONE

Append mode value

BOLD

public const string SetaPDF_Core_Document_OutlinesItem::BOLD = 'bold'

Configuration key

COLOR

public const string SetaPDF_Core_Document_OutlinesItem::COLOR = 'color'

Configuration key

DEST

public const string SetaPDF_Core_Document_OutlinesItem::DEST = 'destination'

Configuration key

ITALIC

public const string SetaPDF_Core_Document_OutlinesItem::ITALIC = 'italic'

Configuration key

MOVE_MODE_APPEND

Move mode value

MOVE_MODE_APPEND_CHILD

public const string SetaPDF_Core_Document_OutlinesItem::MOVE_MODE_APPEND_CHILD = 'appendChild'

Move mode value

MOVE_MODE_PREPEND

public const string SetaPDF_Core_Document_OutlinesItem::MOVE_MODE_PREPEND = 'prepend'

Move mode value

TITLE

public const string SetaPDF_Core_Document_OutlinesItem::TITLE = 'title'

Configuration key


Properties

$_current

$_indirectReference

The indirect reference for this item (if available)

$_key

Current iterator key


Static Methods

_getHash()

Get a hash of an outline item.

Used for checking cyclic references.

Parameters
$item : SetaPDF_Core_Document_OutlinesItem
 
See

copyItem()

Copies an item.

This method internally removes all relations to its parents or neighboring items.

Parameters
$document : SetaPDF_Core_Document

The document instance in which context the item will be copied

$item : SetaPDF_Core_Document_OutlinesItem

The item to copy

Exceptions

Throws SetaPDF_Core_Type_Exception

create()

public static SetaPDF_Core_Document_OutlinesItem::create (
SetaPDF_Core_Document $document, string|array $titleOrConfig [, array $config = array ( ) ]
): SetaPDF_Core_Document_OutlinesItem

Creates an outline item.

The configuration array could hold keyed values:

$config = array(
    SetaPDF_Core_Document_OutlinesItem::TITLE => string,
    SetaPDF_Core_Document_OutlinesItem::DEST => SetaPDF_Core_Document_Destination|SetaPDF_Core_Type_Array|string,
    SetaPDF_Core_Document_OutlinesItem::ACTION => SetaPDF_Core_Document_Action|SetaPDF_Core_Type_Dictionary,
    SetaPDF_Core_Document_OutlinesItem::COLOR => SetaPDF_Core_DataStructure_Color_Rgb|array
    SetaPDF_Core_Document_OutlinesItem::BOLD => boolean,
    SetaPDF_Core_Document_OutlinesItem::ITALIC => boolean,
);
Parameters
$document : SetaPDF_Core_Document

The document instance in which context the item will be used

$titleOrConfig : string|array

The title or a configuration array

$config : array

A configuration array

Exceptions

Throws SetaPDF_Core_Type_Exception


Methods

__construct()

__clone()

Omit cloning.

Exceptions

Throws BadMethodCallException

_isFlagSet()

protected SetaPDF_Core_Document_OutlinesItem::_isFlagSet (
int $flag
): bool

Checks whether a flag in the F entry is set or not.

Parameters
$flag : int
 

_setFlag()

protected SetaPDF_Core_Document_OutlinesItem::_setFlag (
boolean $value, int $flag
): $this|void

Set or unset a flag in the F entry.

Parameters
$value : boolean
 
$flag : int
 

_updateParentCount()

Increases or decreases the count value in the parent items.

Parameters
$parentPdfDict : SetaPDF_Core_Type_Dictionary|false
 
Exceptions

Throws SetaPDF_Core_Type_Exception

append()

Append another item to this item.

The $mode parameter can be used to specify the way the item will be appended: moved or copied.

Parameters
$item : SetaPDF_Core_Document_OutlinesItem

The item to append

$document : SetaPDF_Core_Document

The document instance in which context the item will be used

$mode : string

The append mode. See SetaPDF_Core_Document_OutlinesItem::APPEND_MODE_XXX constants for details.

Return Values

Returns the SetaPDF_Core_Document_OutlinesItem object for method chaining.

Exceptions

Throws LogicException

Throws InvalidArgumentException

Throws SetaPDF_Core_Type_Exception

appendChild()

Append another item as a child of this item.

The $mode parameter can be used to specify the way the item will be appended: moved or copied.

Parameters
$item : SetaPDF_Core_Document_OutlinesItem

The item to append

$document : SetaPDF_Core_Document

The document instance in which context the item will be used

$mode : string

The append mode. See SetaPDF_Core_Document_OutlinesItem::APPEND_MODE_XXX constants for details.

Return Values

Returns the SetaPDF_Core_Document_OutlinesItem object for method chaining.

Exceptions

Throws InvalidArgumentException

Throws SetaPDF_Core_Type_Exception

Throws SetaPDF_Core_SecHandler_Exception

appendChildCopy()

Appends a copy of another item or outline as a child to this item.

Parameters
$originalItem : SetaPDF_Core_Document_Catalog_Outlines|SetaPDF_Core_Document_OutlinesItem
 
$document : SetaPDF_Core_Document

The document instance in which context the item will be used

Exceptions

Throws SetaPDF_Core_SecHandler_Exception

Throws SetaPDF_Core_Type_Exception

appendCopy()

Appends a copy of another item to this item.

Parameters
$originalItem : SetaPDF_Core_Document_OutlinesItem

The original item

$document : SetaPDF_Core_Document

The document instance in which context the item will be used

Return Values

Returns the SetaPDF_Core_Document_OutlinesItem object for method chaining.

Exceptions

Throws SetaPDF_Core_Type_Exception

close()

Close the item.

Alias for SetaPDF_Core_Document_OutlinesItem::setOpen() with false as its argument.

Return Values

Returns the SetaPDF_Core_Document_OutlinesItem object for method chaining.

Exceptions

Throws SetaPDF_Core_Type_Exception

contains()

public SetaPDF_Core_Document_OutlinesItem::contains (
SetaPDF_Core_Document_OutlinesItem $item [, boolean $checkAgainstThis = true ]
): boolean

Checks if an item is specified in any descendants of this item.

Parameters
$item : SetaPDF_Core_Document_OutlinesItem

The item to check for

$checkAgainstThis : boolean

True to check this instance against the item

Return Values

Whether the item is specified in any descendants of this item.

Exceptions

Throws SetaPDF_Core_Type_Exception

getAction()

Get the action of the item.

Return Values

The action instance or false if no action is defined.

Exceptions

Throws SetaPDF_Core_Type_Exception

getChildren()

getColor()

Get the color of the item.

Return Values

A color object or false if no color is defined.

getCount()

Get the number of visible outline items (value of the Count key).

Total number of visible outline items at all levels of the outline.

getDestination()

Get the destination of the item.

Parameters
$document : SetaPDF_Core_Document

The main document is needed to automatically resolve the destination

Return Values

A destination instance or false if none was defined.

Exceptions

Throws SetaPDF_Core_SecHandler_Exception

Throws SetaPDF_Core_Type_Exception

getDictionary()

getFirstItem()

Get an item instance of the item referenced in the First key.

Exceptions

Throws SetaPDF_Core_Type_Exception

getLastItem()

Get an item instance of the item referenced in the 'Last' key.

Exceptions

Throws SetaPDF_Core_Type_Exception

getNext()

Get an item instance of the item referenced in the Next key.

Exceptions

Throws SetaPDF_Core_Type_Exception

getParent()

Get an item instance of the item referenced in the Parent key.

Exceptions

Throws SetaPDF_Core_Type_Exception

getPrevious()

Get an item instance of the item referenced in the Prev key.

Exceptions

Throws SetaPDF_Core_Type_Exception

getReferenceTo()

getTitle()

public SetaPDF_Core_Document_OutlinesItem::getTitle (
[ string $encoding = 'UTF-8' ]
): string

Get the item title.

Parameters
$encoding : string

The output encoding

Exceptions

Throws SetaPDF_Core_Type_Exception

hasChildren()

Checks if this item has descendants.

See

hasFirstItem()

Checks if this item has a 'First' value set.

The first item is the first item structured under this item. With this method you can check if the item has child items.

Return Values

True if a child item exists - false otherwise.

isBold()

public SetaPDF_Core_Document_OutlinesItem::isBold (
void
): boolean

Checks if the item should be displayed bold.

isItalic()

Checks if the item should be displayed italic.

isOpen()

public SetaPDF_Core_Document_OutlinesItem::isOpen (
void
): null|boolean

Checks whether the item is open or not or if the item does not holds any descendants.

Return Values

Returns true if the item is open, false if it is closed or null if the item does not holds any descendants.

key()

Get the iterator key.

See

move()

Move this item to another item or root outline.

The $mode parameter can be used to specify how the item will be moved.

Parameters
$target : SetaPDF_Core_Document_Catalog_Outlines|SetaPDF_Core_Document_OutlinesItem

The target item

$document : SetaPDF_Core_Document

The document instance in which context the item will be used

$mode : string

The move mode. See SetaPDF_Core_Document_OutlinesItem::MOVE_MODE_XXX constants for details.

Return Values

Returns the SetaPDF_Core_Document_OutlinesItem object for method chaining.

Exceptions

Throws InvalidArgumentException

next()

Get the next item.

See

offsetExists()

public SetaPDF_Core_Document_OutlinesItem::offsetExists (
string|integer $offset
): bool

Checks if an item exists at a specific position.

Parameters
$offset : string|integer

The index being checked

See

offsetGet()

Get an item by a specific position.

Parameters
$offset : string|integer

The index with the value

Return Values

The value at the specified index.

Exceptions

Throws InvalidArgumentException if no item is at the offset.

See

offsetSet()

public SetaPDF_Core_Document_OutlinesItem::offsetSet (
null|string|integer $offset, mixed $value
): void

Set an item at a specific position.

Parameters
$offset : null|string|integer

The index being set

$value : mixed

The new value for the index

Exceptions

Throws SetaPDF_Core_SecHandler_Exception

Throws SetaPDF_Core_Type_Exception

See

offsetUnset()

Removes an item at a specific position.

Parameters
$offset : string|integer

The index being unset

Exceptions

Throws SetaPDF_Core_Type_Exception

See

open()

Open the item.

Return Values

Returns the SetaPDF_Core_Document_OutlinesItem object for method chaining.

Exceptions

Throws SetaPDF_Core_Type_Exception

prepend()

Prepend another item to this item.

The $mode parameter can be used to specify the way the item will be prepended: moved or copied.

Parameters
$item : SetaPDF_Core_Document_OutlinesItem

The item to prepend

$document : SetaPDF_Core_Document

The document instance in which context the item will be used

$mode : string

The append mode. See SetaPDF_Core_Document_OutlinesItem::APPEND_MODE_XXX constants for details.

Return Values

Returns the passed item or the last node in the item structure.

Exceptions

Throws LogicException

Throws InvalidArgumentException

Throws SetaPDF_Core_Type_Exception

prependCopy()

Prepends a copy of another item to this item.

Parameters
$originalItem : SetaPDF_Core_Document_OutlinesItem

The original item

$document : SetaPDF_Core_Document

The document instance in which context the item will be used

Return Values

Returns the SetaPDF_Core_Document_OutlinesItem object for method chaining.

Exceptions

Throws SetaPDF_Core_Type_Exception

remove()

Remove the item from the outline.

Return Values

The removed item

Exceptions

Throws SetaPDF_Core_Type_Exception

rewind()

Reset the iterator.

See

setAction()

Set the action of the item.

The action could be an instance of SetaPDF_Core_Document_Action, a dictionary or a reference to a dictionary representing the action.

Parameters
$action : SetaPDF_Core_Document_Action|SetaPDF_Core_Type_IndirectObject|SetaPDF_Core_Type_IndirectReference|SetaPDF_Core_Type_Dictionary|null

The action to execute

Return Values

Returns the SetaPDF_Core_Document_OutlinesItem object for method chaining.

Exceptions

Throws InvalidArgumentException

Throws SetaPDF_Core_Type_Exception

setBold()

Sets whether the item should be displayed bold or not.

Parameters
$bold : boolean

True to display the item bold

Return Values

Returns the SetaPDF_Core_Document_OutlinesItem object for method chaining.

setColor()

public SetaPDF_Core_Document_OutlinesItem::setColor (
array|SetaPDF_Core_DataStructure_Color_Rgb|float $colorOrR [, float $g = null [, float $b = null ]]
): SetaPDF_Core_Document_OutlinesItem

Set the color of the item.

Parameters
$colorOrR : array|SetaPDF_Core_DataStructure_Color_Rgb|float

An array of 3 integer values representing the rgb components (between 0 and 1), an instance of SetaPDF_Core_DataStructure_Color_Rgb or the red component value (between 0 and 1).

$g : float

The green component value (between 0 and 1)

$b : float

The blue component value (between 0 and 1)

Return Values

Returns the SetaPDF_Core_Document_OutlinesItem object for method chaining.

setItalic()

Sets whether the item should be displayed italic or not.

Parameters
$italic : boolean

True to display the item italic

Return Values

Returns the SetaPDF_Core_Document_OutlinesItem object for method chaining.

setOpen()

Open or close the item.

Parameters
$open : boolean

A boolean value specifying if the item is opened or not

Return Values

Returns the SetaPDF_Core_Document_OutlinesItem object for method chaining.

Exceptions

Throws SetaPDF_Core_Type_Exception

setTitle()

public SetaPDF_Core_Document_OutlinesItem::setTitle (
string $title [, string $encoding = 'UTF-8' ]
): SetaPDF_Core_Document_OutlinesItem

Set the item title.

Parameters
$title : string

The item title

$encoding : string

The input encoding

Return Values

Returns the SetaPDF_Core_Document_OutlinesItem object for method chaining.

valid()

Checks whether the pointer of the iterator is valid or not.

See