SetaPDF_Core_Document_Info Class for handling the documents info dictionary

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

Class hierarchy

Summary

Constants

TRAPPED_FALSE

public const string SetaPDF_Core_Document_Info::TRAPPED_FALSE = 'False'

Value for the Trapped property

See

TRAPPED_TRUE

public const string SetaPDF_Core_Document_Info::TRAPPED_TRUE = 'True'

Value for the Trapped property

See

TRAPPED_UNKNOWN

public const string SetaPDF_Core_Document_Info::TRAPPED_UNKNOWN = 'Unknown'

Value for the Trapped property

See

Properties

$_document

$_metadata

The XMP metadata instance

$_syncMetadata

Defines if the XMP metadata should be synced or not

$_xmp

The XMP helper instance

$xmlAliases


Methods

__construct()

The constructor.

Parameters
$document : SetaPDF_Core_Document
 

_extractParts()

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

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

Parameters
$value : string
 

_getAllCustomMetadataKeys()

Get all custom metadata keys

_getDateValue()

protected SetaPDF_Core_Document_Info::_getDateValue (
string $name, boolean $asString
): null|string|SetaPDF_Core_DataStructure_Date

Get a data value.

Parameters
$name : string
 
$asString : boolean
 
Exceptions

Throws Exception

_getStringValue()

protected SetaPDF_Core_Document_Info::_getStringValue (
string $name, string $encoding
): null|string

Get a string value from the info dictionary.

Parameters
$name : string
 
$encoding : string
 

_setStringValue()

protected SetaPDF_Core_Document_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 SetaPDF_Core_SecHandler_Exception

_syncAuthor()

protected SetaPDF_Core_Document_Info::_syncAuthor (
void
): void

Syncs author with XMP metadata package.

Exceptions

Throws SetaPDF_Core_SecHandler_Exception

Throws SetaPDF_Core_Type_Exception

_syncCreationDate()

Syncs creation date with XMP metadata package.

Exceptions

Throws Exception

_syncCreator()

protected SetaPDF_Core_Document_Info::_syncCreator (
void
): void

Syncs creator with XMP metadata package.

Exceptions

Throws SetaPDF_Core_SecHandler_Exception

Throws SetaPDF_Core_Type_Exception

_syncCustomMetadata()

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

Syncs custom metadata with the XMP metadata package.

Parameters
$name : string

The name of the custom metadata

Exceptions

Throws SetaPDF_Core_SecHandler_Exception

Throws SetaPDF_Core_Type_Exception

_syncKeywords()

protected SetaPDF_Core_Document_Info::_syncKeywords (
void
): void

Syncs keywords with XMP metadata package.

Exceptions

Throws SetaPDF_Core_SecHandler_Exception

Throws SetaPDF_Core_Type_Exception

_syncModDate()

protected SetaPDF_Core_Document_Info::_syncModDate (
void
): void

Syncs modification date with XMP metadata package.

Exceptions

Throws Exception

_syncProducer()

protected SetaPDF_Core_Document_Info::_syncProducer (
void
): void

Syncs producer with XMP metadata package.

Exceptions

Throws SetaPDF_Core_SecHandler_Exception

Throws SetaPDF_Core_Type_Exception

_syncSubject()

protected SetaPDF_Core_Document_Info::_syncSubject (
void
): void

Syncs subject with XMP metadata package.

Exceptions

Throws SetaPDF_Core_SecHandler_Exception

Throws SetaPDF_Core_Type_Exception

_syncTitle()

public SetaPDF_Core_Document_Info::_syncTitle (
void
): void

Syncs title with XMP metadata package.

Exceptions

Throws SetaPDF_Core_SecHandler_Exception

Throws SetaPDF_Core_Type_Exception

_syncTrapped()

protected SetaPDF_Core_Document_Info::_syncTrapped (
void
): void

Syncs the XMP metadata package.

Exceptions

Throws SetaPDF_Core_SecHandler_Exception

Throws SetaPDF_Core_Type_Exception

cleanUp()

public SetaPDF_Core_Document_Info::cleanUp (
void
): void

Release memory.

getAll()

public SetaPDF_Core_Document_Info::getAll (
[ string $encoding = 'UTF-8' ]
): array

Get all data from the info dictionary.

Parameters
$encoding : string

The output encoding

Return Values

An key/value array of all metadata.

getAllCustomMetadata()

public SetaPDF_Core_Document_Info::getAllCustomMetadata (
[ string $encoding = 'UTF-8' ]
): array

Get all custom metadata.

Parameters
$encoding : string

The output encoding

getAuthor()

public SetaPDF_Core_Document_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 SetaPDF_Core_Document_Info::getCreationDate (
[ boolean $asString = true ]
): null|string|SetaPDF_Core_DataStructure_Date

Get the date and time the document was created.

Parameters
$asString : boolean
 
Exceptions

Throws Exception

getCreator()

public SetaPDF_Core_Document_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 SetaPDF_Core_Document_Info::getCustomMetadata (
string $name [, string $encoding = 'UTF-8' ]
): null|string

Get a custom metadata value.

Parameters
$name : string

The name of the custom metadata value

$encoding : string

The output encoding

getDictionary()

public SetaPDF_Core_Document_Info::getDictionary (
[ boolean $create = false ]
): null|SetaPDF_Core_Type_Dictionary

Get and/or creates the info dictionary.

Parameters
$create : boolean

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!

public SetaPDF_Core_Document_Info::getInfoDictionary (
[ boolean $create = false ]
): null|SetaPDF_Core_Type_Dictionary

Alias for getDictionary().

Parameters
$create : boolean

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 SetaPDF_Core_Document_Info::getKeywords (
[ string $encoding = 'UTF-8' ]
): string

Get keywords associated with the document.

Parameters
$encoding : string

The output encoding

getMetadata()

Get the metadata DOMDocument instance.

Return Values

Returns a DOMDocument instance of the XMP metadata package.

Exceptions

Throws SetaPDF_Core_SecHandler_Exception

Throws SetaPDF_Core_Type_Exception

Throws Exception

getModDate()

public SetaPDF_Core_Document_Info::getModDate (
[ bool $asString = true ]
): null|string|SetaPDF_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 SetaPDF_Core_DataStructure_Date object.

Exceptions

Throws Exception

getProducer()

public SetaPDF_Core_Document_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 SetaPDF_Core_Document_Info::getSubject (
[ string $encoding = 'UTF-8' ]
): string

Get the subject of the document.

Parameters
$encoding : string

The output encoding

getSyncMetadata()

Gets whether XMP metadata should be synced automatically.

getTitle()

public SetaPDF_Core_Document_Info::getTitle (
[ string $encoding = 'UTF-8' ]
): string|null

Get the document's title.

Parameters
$encoding : string

The output encoding

getTrapped()

public SetaPDF_Core_Document_Info::getTrapped (
[ boolean $default = true ]
): string

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

Parameters
$default : boolean

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

getXmp()

setAll()

public SetaPDF_Core_Document_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

An key/value array of metadata

$encoding : string

The input encoding

Exceptions

Throws SetaPDF_Core_SecHandler_Exception

Throws SetaPDF_Core_Type_Exception

setAuthor()

public SetaPDF_Core_Document_Info::setAuthor (
string $author [, string $encoding = 'UTF-8' ]
): SetaPDF_Core_Document_Info

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

Return Values

Returns the SetaPDF_Core_Document_Info object for method chaining.

Exceptions

Throws SetaPDF_Core_SecHandler_Exception

Throws SetaPDF_Core_Type_Exception

setCreationDate()

Set the date and time the document was created.

Parameters
$date : string|DateTime|SetaPDF_Core_DataStructure_Date
 
Return Values

Returns the SetaPDF_Core_Document_Info object for method chaining.

Exceptions

Throws SetaPDF_Core_SecHandler_Exception

Throws Exception

setCreator()

public SetaPDF_Core_Document_Info::setCreator (
string $creator [, string $encoding = 'UTF-8' ]
): SetaPDF_Core_Document_Info

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

Return Values

Returns the SetaPDF_Core_Document_Info object for method chaining.

Exceptions

Throws SetaPDF_Core_SecHandler_Exception

Throws SetaPDF_Core_Type_Exception

setCustomMetadata()

public SetaPDF_Core_Document_Info::setCustomMetadata (
string $name, string $value [, string $encoding = 'UTF-8' ]
): SetaPDF_Core_Document_Info

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

Return Values

Returns the SetaPDF_Core_Document_Info object for method chaining.

Exceptions

Throws SetaPDF_Core_SecHandler_Exception

Throws InvalidArgumentException

Throws SetaPDF_Core_Type_Exception

setKeywords()

public SetaPDF_Core_Document_Info::setKeywords (
string $keywords [, string $encoding = 'UTF-8' ]
): SetaPDF_Core_Document_Info

Set keywords associated with the document.

Parameters
$keywords : string

The keywords associated with the document.

$encoding : string

The input encoding

Return Values

Returns the SetaPDF_Core_Document_Info object for method chaining.

Exceptions

Throws SetaPDF_Core_SecHandler_Exception

Throws SetaPDF_Core_Type_Exception

setModDate()

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

Parameters
$date : string|DateTime|SetaPDF_Core_DataStructure_Date

The modification date

Return Values

Returns the SetaPDF_Core_Document_Info object for method chaining.

Exceptions

Throws Exception

setProducer()

public SetaPDF_Core_Document_Info::setProducer (
string $producer [, string $encoding = 'UTF-8' ]
): SetaPDF_Core_Document_Info

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

Return Values

Returns the SetaPDF_Core_Document_Info object for method chaining.

Exceptions

Throws SetaPDF_Core_SecHandler_Exception

Throws SetaPDF_Core_Type_Exception

setSubject()

public SetaPDF_Core_Document_Info::setSubject (
string $subject [, string $encoding = 'UTF-8' ]
): SetaPDF_Core_Document_Info

Set the subject of the document.

Parameters
$subject : string

The subject of the document

$encoding : string

The input encoding

Return Values

Returns the SetaPDF_Core_Document_Info object for method chaining.

Exceptions

Throws SetaPDF_Core_SecHandler_Exception

Throws SetaPDF_Core_Type_Exception

setSyncMetadata()

public SetaPDF_Core_Document_Info::setSyncMetadata (
[ bool $syncMetadata = true ]
): SetaPDF_Core_Document_Info

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

Return Values

Returns the SetaPDF_Core_Document_Info object for method chaining.

setTitle()

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

Set the document's title.

Parameters
$title : string

The document's title

$encoding : string

The input encoding

Return Values

Returns the SetaPDF_Core_Document_Info object for method chaining.

Exceptions

Throws SetaPDF_Core_SecHandler_Exception

Throws SetaPDF_Core_Type_Exception

setTrapped()

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

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

Parameters
$trapped : string

The trapped value. See SetaPDF_Core_Document_Info::TRAPPED_XXX constants.

Return Values

Returns the SetaPDF_Core_Document_Info object for method chaining.

Exceptions

Throws SetaPDF_Core_SecHandler_Exception

Throws SetaPDF_Core_Type_Exception

syncMetadata()

Passes the changes to the XMP metadata package.

Exceptions

Throws SetaPDF_Core_SecHandler_Exception

Throws SetaPDF_Core_Type_Exception

updateXmp()

public SetaPDF_Core_Document_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 SetaPDF_Core_SecHandler_Exception

Throws SetaPDF_Core_Type_Exception