setasign\SetaPDF2\Core\Document\Catalog

OptionalContent Class for handling optional content

File: /SetaPDF v2/Core/Document/Catalog/OptionalContent.php
Old class name (alias): \SetaPDF_Core_Document_Catalog_OptionalContent

Class hierarchy

Implements

Summary

Constants

STATE_OFF

public const string OptionalContent::STATE_OFF = 'OFF'

State constant

STATE_ON

public const string OptionalContent::STATE_ON = 'ON'

State constant

STATE_UNCHANGED

public const string OptionalContent::STATE_UNCHANGED = 'Unchanged'

State constant


Properties

$_catalog

The documents catalog instance

$_propertiesDictionary

The optional contents properties dictionary


Methods

__construct()

_getArrayFromDefaultViewing()

protected OptionalContent::_getArrayFromDefaultViewing (
string $name,
bool $create = false
): ?\setasign\SetaPDF2\Core\Type\PdfArray

Get and/or create an array entry in the default viewing dictionary.

Parameters
$name : string
 
$create : bool
 
Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

addGroup()

This method adds a method to the OCGs array.

By adding a group with this method the group will not be added to the user interface.

Parameters
$group : \setasign\SetaPDF2\Core\Document\OptionalContent\Group|string
 
Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

addUsageApplication()

Create and add usage application dictionaries for the given optional content group.

The usage definition in an optional content group will only apply to automatically adjustment if the group is referenced by a usage application dictionary.

$triangle = $optionalContent->appendGroup('Triangle');
// Define the usage
$triangle->usage()->setPrintState(\setasign\SetaPDF2\Core\Document\Catalog\OptionalContent::STATE_OFF);
// Now add it to an usage application dictionary
$optionalContent->addUsageApplication($triangle);
Parameters
$group : \setasign\SetaPDF2\Core\Document\OptionalContent\Group
 
Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

See

appendGroup()

cleanUp()

public OptionalContent::cleanUp (
void
): void

Release resources / cycled references.

getAsArray()

Get and/or create the AS array in the default viewing dictionary.

Parameters
$create : bool
 
Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

See
  • PDF 32000-1:2008 - 8.11.4.3 Optional Content Configuration Dictionaries

getBaseState()

public OptionalContent::getBaseState (
void
): string

Get the base state from the default viewing dictionary.

Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

See
  • PDF 32000-1:2008 - 8.11.4.3 Optional Content Configuration Dictionaries

getDefaultViewingDictionary()

Get the default viewing dictionary.

Parameters
$create : bool
 
Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

See
  • PDF 32000-1:2008 - 8.11.4.2 Optional Content Properties Dictionary

getDocument()

Get the document instance.

getGroup()

public OptionalContent::getGroup (
string $name,
string $encoding = 'UTF-8'
): false|\setasign\SetaPDF2\Core\Document\OptionalContent\Group

Get a group by its name.

Parameters
$name : string

The group name

$encoding : string

The input encoding

Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

getOffArray()

Get and/or create the OFF array in the default viewing dictionary.

Parameters
$create : bool
 
Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

See
  • PDF 32000-1:2008 - 8.11.4.3 Optional Content Configuration Dictionaries

getOnArray()

Get and/or create the ON array in the default viewing dictionary.

Parameters
$create : bool
 
Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

See
  • PDF 32000-1:2008 - 8.11.4.3 Optional Content Configuration Dictionaries

getOptionalContentPropertiesDictionary()

Get and creates the optional content properties dictionary.

Parameters
$create : bool
 
Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

getOrderArray()

Get and/or create the Order array in the default viewing dictionary.

Parameters
$create : bool
 
Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

See
  • PDF 32000-1:2008 - 8.11.4.3 Optional Content Configuration Dictionaries

prependGroup()

Prepends an optional content group to the outline structure.

If the $beforeIndex parameter is out of range the group will be appended.

Parameters
$group : string|\setasign\SetaPDF2\Core\Document\OptionalContent\Group
 
$parent : ?\setasign\SetaPDF2\Core\Document\OptionalContent\Group
 
$beforeIndex : ?int
 
$nextToOrLabel : string|\setasign\SetaPDF2\Core\Document\OptionalContent\Group
 
$label : string
 
Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

setBaseState()

public OptionalContent::setBaseState (
string $baseState
): void

Set the base state in the default viewing dictionary.

Parameters
$baseState : string
 
Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

See
  • PDF 32000-1:2008 - 8.11.4.3 Optional Content Configuration Dictionaries

setOff()

setOn()