setasign\SetaPDF2\Merger

Collection Class for creating and managing PDF Collections (aka Portfolios, or Packages).

File: /SetaPDF v2/Merger/Collection.php
Old class name (alias): \SetaPDF_Merger_Collection

Class hierarchy

Summary

Constants

SORT_ASC

public const bool Collection::SORT_ASC = true

Sort in ascending order.

SORT_DESC

public const string Collection::SORT_DESC = false

Sort in descending order.

SPLIT_HORIZONTALLY

public const string Collection::SPLIT_HORIZONTALLY = 'H'

Indicates that the window is split horizontally.

SPLIT_NO

public const string Collection::SPLIT_NO = 'N'

Indicates that the window is not split. The entire window region shall be dedicated to the file navigation view.

SPLIT_VERTICALLY

public const string Collection::SPLIT_VERTICALLY = 'V'

Indicates that the window is split vertically.

VIEW_DETAILS

public const string Collection::VIEW_DETAILS = 'D'

The collection view shall be presented in details mode.

VIEW_HIDDEN

public const string Collection::VIEW_HIDDEN = 'H'

The collection view shall be initially hidden.

VIEW_NAVIGATOR

public const string Collection::VIEW_NAVIGATOR = 'C'

The collection view shall be presented by the navigator specified by the Navigator entry.

VIEW_TILE

public const string Collection::VIEW_TILE = 'T'

The collection view shall be presented in tile mode.


Properties

$_document

The document instance of the cover sheet.

$_schema

The schema instance.


Methods

__construct()

_getSplitDictionary()

Get and/or creates the split dictionary.

Parameters
$create : bool
 
Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

addFile()

public Collection::addFile (
\SetaPDF_Core_Reader_ReaderInterface|string $pathOrReader,
string $filename,
?string $description = null,
array $fileStreamParams = array ( ),
?string $mimeType = null,
null|array|\SetaPDF_Merger_Collection_Item $collectionItem = null
): string

Add a file to the collection.

Parameters
$pathOrReader : \SetaPDF_Core_Reader_ReaderInterface|string

A reader instance or a path to a file.

$filename : string

The filename in UTF-8 encoding.

$description : ?string

The description of the file in UTF-8 encoding.

$fileStreamParams : array

See \setasign\SetaPDF2\Core\EmbeddedFileStream::setParams() method.

$mimeType : ?string

The subtype of the embedded file. Shall conform to the MIME media type names defined in Internet RFC 2046

$collectionItem : null|array|\SetaPDF_Merger_Collection_Item

The data described by the collection schema.

Return Values

The name that was used to register the file specification in the embedded files name tree.

Exceptions

Throws \setasign\SetaPDF2\Core\DataStructure\Tree\KeyAlreadyExistsException

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

addFolder()

public Collection::addFolder (
string $name,
?string $description = null,
?\DateTime $creationDate = null,
?\DateTime $modificationDate = null,
null|array|\SetaPDF_Merger_Collection_Item $collectionItem = null
): \SetaPDF_Merger_Collection_Folder

Add a folder to the collection.

Parameters
$name : string

The folder name.

$description : ?string

The description of the folder.

$creationDate : ?\DateTime

If null "now" will be used.

$modificationDate : ?\DateTime

If null "now" will be used.

$collectionItem : null|array|\SetaPDF_Merger_Collection_Item

The data described by the collection schema.

Exceptions

Throws \setasign\SetaPDF2\Core\Document\ObjectNotFoundException

Throws \setasign\SetaPDF2\Core\Exception

Throws \setasign\SetaPDF2\Core\Parser\Pdf\InvalidTokenException

Throws \setasign\SetaPDF2\Core\Reader\Exception

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

Throws \setasign\SetaPDF2\Core\Type\IndirectReference\Exception

Throws \setasign\SetaPDF2\Exception

Throws \setasign\SetaPDF2\NotImplementedException

Throws Exception

cleanUp()

public Collection::cleanUp (
void
): void

Release cylced referenced.

deleteFile()

public Collection::deleteFile (
string $name
): bool

Removes a file from the collection.

If the file doesn't exist false will be returned.

Parameters
$name : string

The name with which the file is registered in the documents embedded files name tree.

Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

getDictionary()

public Collection::getDictionary (
bool $create = false
): ?\SetaPDF_Core_Type_Dictionary

Get the collection dictionary.

Parameters
$create : bool
 
Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

getDocument()

Get the document instance.

getFile()

public Collection::getFile (
string $name
): false|\SetaPDF_Core_FileSpecification

Get a file by its name in the embedded files name tree.

Parameters
$name : string
 
Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

getFiles()

Get all embedded files from this collection/document.

Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

getInitialDocument()

public Collection::getInitialDocument (
void
): ?string

Get the name of the document, that should be initially presented.

Return Values

Null if it is not defined.

Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

getRootFolder()

Get and/or created the root folder instance.

To ensure that a root folder is created pass true as the $create parameter.

Parameters
$create : bool

Defines whether to create the folder if it does not exists or not.

Exceptions

Throws \setasign\SetaPDF2\Core\Document\ObjectNotFoundException

Throws \setasign\SetaPDF2\Core\Exception

Throws \setasign\SetaPDF2\Core\Parser\Pdf\InvalidTokenException

Throws \setasign\SetaPDF2\Core\Reader\Exception

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

Throws \setasign\SetaPDF2\Core\Type\IndirectReference\Exception

Throws \setasign\SetaPDF2\Exception

Throws \setasign\SetaPDF2\NotImplementedException

getSchema()

Get the schema instance.

getSort()

public Collection::getSort (
void
): array

Get the data which specifies the order in which in the collection shall be sorted in the user interface.

Return Values

The key is the field name, while the value describing the direction.

Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

See

getSplitterDirection()

public Collection::getSplitterDirection (
void
): ?string

Get the orientation of the splitter bar.

Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

getSplitterPosition()

public Collection::getSplitterPosition (
void
): ?number

Get the initial position of the splitter bar.

Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

getView()

public Collection::getView (
void
): string

Get the initial view.

Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

isCollection()

public Collection::isCollection (
void
): bool

Checks whether the document instance has the Collection dictionary defined or not.

Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

setInitialDocument()

public Collection::setInitialDocument (
string $name
): void

Set the name of the document, that should be initially presented.

If you want to open a document, that is located in a subfolder, you will need to pass the id of the subfolder as a prefix to the name:

$collection->setInitialDocument('<' . $folder->getId() . '>' . $name);
Parameters
$name : string
 
Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

setSort()

public Collection::setSort (
array $sort
): void

Set the data that specifies the order in which the collection shall be sorted in the user interface.

Parameters
$sort : array

The key is the field name, while the value defines the direction. Valid key names are field names defined in the schema or Collection\Schema::DATA_* constants.

Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

See

setSplitterDirection()

public Collection::setSplitterDirection (
string $direction
): void

Set the orientation of the splitter bar.

Parameters
$direction : string
 
Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

setSplitterPosition()

public Collection::setSplitterPosition (
number $position
): void

Set the initial position of the splitter bar.

Parameters
$position : number
 
Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

setView()

public Collection::setView (
string $view
): void

Set the initial view.

Parameters
$view : string

A view constant.

Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

See