setasign\SetaPDF2\Core\Document

OutlinesItem Class representing an outline item

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

Class hierarchy

Implements

Summary

Constants

ACTION

public const string OutlinesItem::ACTION = 'action'

Configuration key

APPEND_MODE_COPY

public const string OutlinesItem::APPEND_MODE_COPY = 'copy'

Append mode value

APPEND_MODE_MOVE

public const string OutlinesItem::APPEND_MODE_MOVE = 'move'

Append mode value

APPEND_MODE_NONE

public const null OutlinesItem::APPEND_MODE_NONE = NULL

Append mode value

BOLD

public const string OutlinesItem::BOLD = 'bold'

Configuration key

COLOR

public const string OutlinesItem::COLOR = 'color'

Configuration key

DEST

public const string OutlinesItem::DEST = 'destination'

Configuration key

ITALIC

public const string OutlinesItem::ITALIC = 'italic'

Configuration key

MOVE_MODE_APPEND

public const string OutlinesItem::MOVE_MODE_APPEND = 'append'

Move mode value

MOVE_MODE_APPEND_CHILD

public const string OutlinesItem::MOVE_MODE_APPEND_CHILD = 'appendChild'

Move mode value

MOVE_MODE_PREPEND

public const string OutlinesItem::MOVE_MODE_PREPEND = 'prepend'

Move mode value

TITLE

public const string OutlinesItem::TITLE = 'title'

Configuration key


Properties

$_current

The current iterator item

$_dictionary

$_indirectReference

The indirect reference for this item (if available)

$_key

protected int OutlinesItem::$_key = 0

Current iterator key


Static Methods

_getHash()

private static OutlinesItem::_getHash (
self $item
): string

Get a hash of an outline item.

Used for checking cyclic references.

Parameters
$item : self
 
See

copyItem()

Copies an item.

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

Parameters
$document : \setasign\SetaPDF2\Core\Document

The document instance in which context the item will be copied

$item : OutlinesItem

The item to copy

Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

create()

public static OutlinesItem::create (
\setasign\SetaPDF2\Core\Document $document,
string|array $titleOrConfig,
array $config = array ( )
): OutlinesItem

Creates an outline item.

The configuration array could hold keyed values:

$config = array(
    \setasign\SetaPDF2\Core\Document\OutlinesItem::TITLE => string,
    \setasign\SetaPDF2\Core\Document\OutlinesItem::DEST => \setasign\SetaPDF2\Core\Document\Destination|\setasign\SetaPDF2\Core\Type\PdfArray|string,
    \setasign\SetaPDF2\Core\Document\OutlinesItem::ACTION => \setasign\SetaPDF2\Core\Document\Action\Action|\setasign\SetaPDF2\Core\Type\PdfDictionary,
    \setasign\SetaPDF2\Core\Document\OutlinesItem::COLOR => \setasign\SetaPDF2\Core\DataStructure\Color\Rgb|array
    \setasign\SetaPDF2\Core\Document\OutlinesItem::BOLD => bool,
    \setasign\SetaPDF2\Core\Document\OutlinesItem::ITALIC => bool,
);
Parameters
$document : \setasign\SetaPDF2\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 \setasign\SetaPDF2\Core\Type\Exception


Methods

__construct()

__clone()

public OutlinesItem::__clone (
void
): void

Omit cloning.

Exceptions

Throws \BadMethodCallException

_isFlagSet()

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

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

Parameters
$flag : int
 

_setFlag()

protected OutlinesItem::_setFlag (
bool $value,
int $flag
): $this|void

Set or unset a flag in the F entry.

Parameters
$value : bool
 
$flag : int
 

_updateParentCount()

Increases or decreases the count value in the parent items.

Parameters
$parentPdfDict : \setasign\SetaPDF2\Core\Type\PdfDictionary|false
 
Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

append()

public OutlinesItem::append (
OutlinesItem $item,
?\setasign\SetaPDF2\Core\Document $document = null,
?string $mode = null
): $this

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 : OutlinesItem

The item to append

$document : ?\setasign\SetaPDF2\Core\Document

The document instance in which context the item will be used

$mode : ?string

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

Exceptions

Throws \LogicException

Throws \InvalidArgumentException

Throws \setasign\SetaPDF2\Core\Type\Exception

appendChild()

public OutlinesItem::appendChild (
self $item,
?\setasign\SetaPDF2\Core\Document $document = null,
string $mode = null
): $this

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 : self

The item to append

$document : ?\setasign\SetaPDF2\Core\Document

The document instance in which context the item will be used

$mode : string

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

Exceptions

Throws \InvalidArgumentException

Throws \setasign\SetaPDF2\Core\Type\Exception

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

appendChildCopy()

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

Parameters
$originalItem : Catalog\Outlines|OutlinesItem
 
$document : \setasign\SetaPDF2\Core\Document

The document instance in which context the item will be used

Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

appendCopy()

Appends a copy of another item to this item.

Parameters
$originalItem : OutlinesItem

The original item

$document : \setasign\SetaPDF2\Core\Document

The document instance in which context the item will be used

Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

close()

public OutlinesItem::close (
void
): $this

Close the item.

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

Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

contains()

public OutlinesItem::contains (
OutlinesItem $item,
bool $checkAgainstThis = true
): bool

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

Parameters
$item : OutlinesItem

The item to check for

$checkAgainstThis : bool

True to check this instance against the item

Return Values

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

Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

current()

Get the current item.

See

getAction()

public OutlinesItem::getAction (
void
): bool|Action\Action

Get the action of the item.

Return Values

The action instance or false if no action is defined.

Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

getChildren()

public OutlinesItem::getChildren (
void
): OutlinesItem|false

Get the first descendant item.

Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

See

getColor()

Get the color of the item.

Return Values

A color object or false if no color is defined.

getCount()

public OutlinesItem::getCount (
void
): int

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 : ?\setasign\SetaPDF2\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 \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

getDictionary()

getFirstItem()

public OutlinesItem::getFirstItem (
void
): bool|OutlinesItem

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

Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

getIndirectReference()

Get the indirect reference to this item.

getLastItem()

public OutlinesItem::getLastItem (
void
): bool|OutlinesItem

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

Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

getNext()

public OutlinesItem::getNext (
void
): bool|OutlinesItem

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

Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

getParent()

public OutlinesItem::getParent (
void
): bool|OutlinesItem

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

Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

getPrevious()

public OutlinesItem::getPrevious (
void
): bool|OutlinesItem

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

Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

getReferenceTo()

WARNING: This method is marked as deprecated!

Use getIndirectReference() instead

Get the reference to this item.

getTitle()

public OutlinesItem::getTitle (
string $encoding = 'UTF-8'
): string

Get the item title.

Parameters
$encoding : string

The output encoding

Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

hasChildren()

public OutlinesItem::hasChildren (
void
): void

Checks if this item has descendants.

See

hasFirstItem()

public OutlinesItem::hasFirstItem (
void
): bool

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 OutlinesItem::isBold (
void
): bool

Checks if the item should be displayed bold.

isItalic()

public OutlinesItem::isItalic (
void
): bool

Checks if the item should be displayed italic.

isOpen()

public OutlinesItem::isOpen (
void
): ?bool

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

Return Values

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

key()

public OutlinesItem::key (
void
): int

Get the iterator key.

See

move()

public OutlinesItem::move (
Catalog\Outlines|OutlinesItem $target,
\setasign\SetaPDF2\Core\Document $document,
string $mode = 'appendChild'
): $this

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 : Catalog\Outlines|OutlinesItem

The target item

$document : \setasign\SetaPDF2\Core\Document

The document instance in which context the item will be used

$mode : string

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

Exceptions

Throws \InvalidArgumentException

next()

public OutlinesItem::next (
void
): void

Get the next item.

See

offsetExists()

public OutlinesItem::offsetExists (
string|int $offset
): bool

Checks if an item exists at a specific position.

Parameters
$offset : string|int

The index being checked

See
  • \setasign\SetaPDF2\Core\Document\ArrayAccess::offsetExists()

offsetGet()

public OutlinesItem::offsetGet (
string|int $offset
): OutlinesItem

Get an item by a specific position.

Parameters
$offset : string|int

The index with the value

Return Values

The value at the specified index.

Exceptions

Throws \InvalidArgumentException if no item is at the offset.

See
  • \setasign\SetaPDF2\Core\Document\ArrayAccess::offsetGet()

offsetSet()

public OutlinesItem::offsetSet (
null|string|int $offset,
mixed $value
): void

Set an item at a specific position.

Parameters
$offset : null|string|int

The index being set

$value : mixed

The new value for the index

Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

See

offsetUnset()

public OutlinesItem::offsetUnset (
string|int $offset
): OutlinesItem

Removes an item at a specific position.

Parameters
$offset : string|int

The index being unset

Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

See
  • \setasign\SetaPDF2\Core\Document\ArrayAccess::offsetUnset()

open()

public OutlinesItem::open (
void
): $this

Open the item.

Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

prepend()

public OutlinesItem::prepend (
OutlinesItem $item,
?\setasign\SetaPDF2\Core\Document $document = null,
string $mode = null
): OutlinesItem

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 : OutlinesItem

The item to prepend

$document : ?\setasign\SetaPDF2\Core\Document

The document instance in which context the item will be used

$mode : string

The append mode. See 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 \setasign\SetaPDF2\Core\Type\Exception

prependCopy()

Prepends a copy of another item to this item.

Parameters
$originalItem : OutlinesItem

The original item

$document : \setasign\SetaPDF2\Core\Document

The document instance in which context the item will be used

Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

remove()

public OutlinesItem::remove (
void
): OutlinesItem

Remove the item from the outline.

Return Values

The removed item

Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

rewind()

public OutlinesItem::rewind (
void
): void

Reset the iterator.

See

setBold()

public OutlinesItem::setBold (
bool $bold = true
): $this

Sets whether the item should be displayed bold or not.

Parameters
$bold : bool

True to display the item bold

setColor()

public OutlinesItem::setColor (
array|\setasign\SetaPDF2\Core\DataStructure\Color\Rgb|float $colorOrR,
float $g = null,
float $b = null
): $this

Set the color of the item.

Parameters
$colorOrR : array|\setasign\SetaPDF2\Core\DataStructure\Color\Rgb|float

An array of 3 integer values representing the rgb components (between 0 and 1), an instance of \setasign\SetaPDF2\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)

setItalic()

public OutlinesItem::setItalic (
bool $italic = true
): $this

Sets whether the item should be displayed italic or not.

Parameters
$italic : bool

True to display the item italic

setOpen()

public OutlinesItem::setOpen (
bool $open = true
): $this

Open or close the item.

Parameters
$open : bool

A bool value specifying if the item is opened or not

Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

setTitle()

public OutlinesItem::setTitle (
string $title,
string $encoding = 'UTF-8'
): $this

Set the item title.

Parameters
$title : string

The item title

$encoding : string

The input encoding

valid()

public OutlinesItem::valid (
void
): bool

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

See