setasign\SetaPDF2\Core\Document

Info Class for handling the documents info dictionary

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

Class hierarchy

Summary

Constants

TRAPPED_FALSE

public const string Info::TRAPPED_FALSE = 'False'

Value for the Trapped property

See

TRAPPED_TRUE

public const string Info::TRAPPED_TRUE = 'True'

Value for the Trapped property

See

TRAPPED_UNKNOWN

public const string Info::TRAPPED_UNKNOWN = 'Unknown'

Value for the Trapped property

See

Properties

$_document

The document instance

$_metadata

The XMP metadata instance

$_syncMetadata

protected bool Info::$_syncMetadata = false

Defines if the XMP metadata should be synced or not

$_xmp

The XMP helper instance

$xmlAliases

public Info::$xmlAliases = array(...)

Methods

__construct()

The constructor.

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

_extractParts()

private Info::_extractParts (
string $value
): array|bool

Extracts single elements from a string and converts them into an array.

Parameters
$value : string
 

_getAllCustomMetadataKeys()

protected Info::_getAllCustomMetadataKeys (
void
): array

Get all custom metadata keys

_getDateValue()

protected Info::_getDateValue (
string $name,
bool $asString
): null|string|\setasign\SetaPDF2\Core\DataStructure\Date

Get a data value.

Parameters
$name : string
 
$asString : bool
 
Exceptions

Throws \Exception

_getStringValue()

protected Info::_getStringValue (
string $name,
string $encoding
): ?string

Get a string value from the info dictionary.

Parameters
$name : string
 
$encoding : string
 

_setStringValue()

protected Info::_setStringValue (
string $name,
string $value,
string $encoding
): void

Set a string value in the info dictionary.

Parameters
$name : string
 
$value : string
 
$encoding : string
 
Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

_syncAuthor()

protected Info::_syncAuthor (
void
): void

Syncs author with XMP metadata package.

Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

_syncCreationDate()

protected Info::_syncCreationDate (
void
): void

Syncs creation date with XMP metadata package.

Exceptions

Throws \Exception

_syncCreator()

protected Info::_syncCreator (
void
): void

Syncs creator with XMP metadata package.

Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

_syncCustomMetadata()

public Info::_syncCustomMetadata (
string $name
): void

Syncs custom metadata with the XMP metadata package.

Parameters
$name : string

The name of the custom metadata

Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

_syncKeywords()

protected Info::_syncKeywords (
void
): void

Syncs keywords with XMP metadata package.

Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

_syncModDate()

protected Info::_syncModDate (
void
): void

Syncs modification date with XMP metadata package.

Exceptions

Throws \Exception

_syncProducer()

protected Info::_syncProducer (
void
): void

Syncs producer with XMP metadata package.

Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

_syncSubject()

protected Info::_syncSubject (
void
): void

Syncs subject with XMP metadata package.

Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

_syncTitle()

public Info::_syncTitle (
void
): void

Syncs title with XMP metadata package.

Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

_syncTrapped()

protected Info::_syncTrapped (
void
): void

Syncs the XMP metadata package.

Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

cleanUp()

public Info::cleanUp (
void
): void

Release memory.

getAll()

public Info::getAll (
string $encoding = 'UTF-8'
): array

Get all data from the info dictionary.

Parameters
$encoding : string

The output encoding

Return Values

A key/value array of all metadata.

getAllCustomMetadata()

public Info::getAllCustomMetadata (
string $encoding = 'UTF-8'
): array

Get all custom metadata.

Parameters
$encoding : string

The output encoding

getAuthor()

public Info::getAuthor (
string $encoding = 'UTF-8'
): string

Get the name of the person who created the document.

Parameters
$encoding : string

The output encoding

getCreationDate()

public Info::getCreationDate (
bool $asString = true
): null|string|\setasign\SetaPDF2\Core\DataStructure\Date

Get the date and time the document was created.

Parameters
$asString : bool
 
Exceptions

Throws \Exception

getCreator()

public Info::getCreator (
string $encoding = 'UTF-8'
): string

Get the name of the product that created the original document from which it was converted.

Parameters
$encoding : string

The output encoding

getCustomMetadata()

public Info::getCustomMetadata (
string $name,
string $encoding = 'UTF-8'
): ?string

Get a custom metadata value.

Parameters
$name : string

The name of the custom metadata value

$encoding : string

The output encoding

getDictionary()

Get and/or creates the info dictionary.

Parameters
$create : bool

Defines if the dictionary should be created if it is not available

Return Values

The dictionary for low level access or null if none is available.

getInfoDictionary()

WARNING: This method is marked as deprecated!

Alias for getDictionary().

Parameters
$create : bool

Defines if the dictionary should be created if it is not available

Return Values

The dictionary for low level access or null if none is available.

getKeywords()

public Info::getKeywords (
string $encoding = 'UTF-8'
): string

Get keywords associated with the document.

Parameters
$encoding : string

The output encoding

getMetadata()

public Info::getMetadata (
void
): \DOMDocument

Get the metadata \DOMDocument instance.

Return Values

Returns a \DOMDocument instance of the XMP metadata package.

Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

Throws \Exception

getModDate()

public Info::getModDate (
bool $asString = true
): null|string|\setasign\SetaPDF2\Core\DataStructure\Date

Get the date and time the document was most recently modified.

Parameters
$asString : bool

If set to true the string value will get returned. Otherwise a \setasign\SetaPDF2\Core\DataStructure\Date object.

Exceptions

Throws \Exception

getProducer()

public Info::getProducer (
string $encoding = 'UTF-8'
): string

Get the name of the product that converted the original document to PDF.

Parameters
$encoding : string

The output encoding.

getSubject()

public Info::getSubject (
string $encoding = 'UTF-8'
): string

Get the subject of the document.

Parameters
$encoding : string

The output encoding

getSyncMetadata()

public Info::getSyncMetadata (
void
): bool

Gets whether XMP metadata should be synced automatically.

getTitle()

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

Get the document's title.

Parameters
$encoding : string

The output encoding

getTrapped()

public Info::getTrapped (
bool $default = true
): string

Get information whether the document has been modified to include trapping information.

Parameters
$default : bool

If set to true and no entry is defined the default value is returned

setAll()

public Info::setAll (
array $data,
string $encoding = 'UTF-8'
): void

Set all data via an array parameter.

This method decides if a value is a custom metadata or a standard value and will forward it to the desired method.

Parameters
$data : array

A key/value array of metadata

$encoding : string

The input encoding

Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

setAuthor()

public Info::setAuthor (
string $author,
string $encoding = 'UTF-8'
): $this

Set the name of the person who created the document.

Parameters
$author : string

The name of the person who created the document

$encoding : string

The input encoding

Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

setCreationDate()

Set the date and time the document was created.

Parameters
$date : string|\DateTime|\setasign\SetaPDF2\Core\DataStructure\Date
 
Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \Exception

setCreator()

public Info::setCreator (
string $creator,
string $encoding = 'UTF-8'
): $this

Set the name of the product that created the original document from which it was converted.

Parameters
$creator : string

The creator

$encoding : string

The input encoding

Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

setCustomMetadata()

public Info::setCustomMetadata (
string $name,
string $value,
string $encoding = 'UTF-8'
): $this

Set custom metadata.

Pass $value as null to remove this entry from the info dictionary.

Parameters
$name : string

The name of the custom metadata

$value : string

The string value of the custom metadata

$encoding : string

The input encoding

Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \InvalidArgumentException

Throws \setasign\SetaPDF2\Core\Type\Exception

setKeywords()

public Info::setKeywords (
string $keywords,
string $encoding = 'UTF-8'
): $this

Set keywords associated with the document.

Parameters
$keywords : string

The keywords associated with the document.

$encoding : string

The input encoding

Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

setModDate()

Set the date and time the document was most recently modified.

Parameters
$date : string|\DateTime|\setasign\SetaPDF2\Core\DataStructure\Date

The modification date

Exceptions

Throws \Exception

setProducer()

public Info::setProducer (
string $producer,
string $encoding = 'UTF-8'
): $this

Set the name of the product that converted the original document to PDF.

Parameters
$producer : string

The name of the producer

$encoding : string

The input encoding

Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

setSubject()

public Info::setSubject (
string $subject,
string $encoding = 'UTF-8'
): $this

Set the subject of the document.

Parameters
$subject : string

The subject of the document

$encoding : string

The input encoding

Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

setSyncMetadata()

public Info::setSyncMetadata (
bool $syncMetadata = true
): $this

Defines if the XMP metadata should be synced automatically.

If this is set, the changes are made to a \DOMDocument instance temporary. A call of syncMetadata() is required to write the changes to the metadata entry in the documents catalog dictionary.

Parameters
$syncMetadata : bool

The flag status

setTitle()

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

Set the document's title.

Parameters
$title : string

The document's title

$encoding : string

The input encoding

Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

setTrapped()

public Info::setTrapped (
string $trapped
): $this

Set information whether the document has been modified to include trapping information.

Pass null or Info::TRAPPED_UNKNOWN to remove this entry from the info dictionary.

Parameters
$trapped : string

The trapped value. See Info::TRAPPED_XXX constants.

Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

syncMetadata()

public Info::syncMetadata (
void
): void

Passes the changes to the XMP metadata package.

Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

updateXmp()

public Info::updateXmp (
string $namespace,
string $tagName,
bool|string|array $value
): void

Updates a single field in the XMP package.

Parameters
$namespace : string

The namespace of the element

$tagName : string

The tag name

$value : bool|string|array

The value

Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception