SetaPDF_Core_Document_Info Class for handling the documents info dictionary

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

Class hierarchy

Summary

Constants

TRAPPED_FALSE

Value for the Trapped property

See

TRAPPED_TRUE

Value for the Trapped property

See

TRAPPED_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

$xmlAliases


Methods

__construct()

The constructor.

Parameters
$document : SetaPDF_Core_Document
 

_encodeTagName()

protected SetaPDF_Core_Document_Info::_encodeTagName (
$tagName
): string

Encodes a tag name as specified in the XMP Specification Part 3 - 3.2.1

Parameters
$tagName
 

_escapeTagChar()

private SetaPDF_Core_Document_Info::_escapeTagChar (
$matches
): string

Call back for _encodeTagName()

Parameters
$matches
 
See

_extractParts()

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

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

Parameters
$value
 

_findDescription()

protected SetaPDF_Core_Document_Info::_findDescription (
string $namespace
): DOMElement

Finds or creates a Description tag with the desired namespace.

Parameters
$namespace : string
 

_getAllCustomMetadataKeys()

Get all custom metadata keys

_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
 

_syncAuthor()

protected SetaPDF_Core_Document_Info::_syncAuthor (
void
): void

Syncs author with XMP metadata package.

_syncCreationDate()

Syncs creation date with XMP metadata package.

_syncCreator()

protected SetaPDF_Core_Document_Info::_syncCreator (
void
): void

Syncs creator with XMP metadata package.

_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

_syncKeywords()

protected SetaPDF_Core_Document_Info::_syncKeywords (
void
): void

Syncs keywords with XMP metadata package.

_syncModDate()

protected SetaPDF_Core_Document_Info::_syncModDate (
void
): void

Syncs modification date with XMP metadata package.

_syncProducer()

protected SetaPDF_Core_Document_Info::_syncProducer (
void
): void

Syncs producer with XMP metadata package.

_syncSubject()

protected SetaPDF_Core_Document_Info::_syncSubject (
void
): void

Syncs subject with XMP metadata package.

_syncTitle()

public SetaPDF_Core_Document_Info::_syncTitle (
void
): void

Syncs title with XMP metadata package.

_syncTrapped()

protected SetaPDF_Core_Document_Info::_syncTrapped (
void
): void

Syncs the XMP metadata package

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
 

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()

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.

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.

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

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

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.

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.

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.

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 InvalidArgumentException

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.

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.

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.

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.

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.

setTrapped()

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

Pass null 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.

syncMetadata()

Passes the changes to the XMP metadata package.

updateXmp()

public SetaPDF_Core_Document_Info::updateXmp (
string $namespace, string $tagName, bool|string $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

The value