SetaPDF_Core_Document_Info Class for handling the documents info dictionary

File: /SetaPDF/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 string SetaPDF_Core_Document_Info::_encodeTagName ( $tagName $tagName )

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

Parameters
$tagName : $tagName
 

_escapeTagChar()

private string SetaPDF_Core_Document_Info::_escapeTagChar ( $matches $matches )

Call back for _encodeTagName()

Parameters
$matches : $matches
 
See

_extractParts()

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

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

Parameters
$value : $value
 

_findDescription()

protected DOMElement SetaPDF_Core_Document_Info::_findDescription ( string $namespace )

Finds or creates a Description tag with the desired namespace.

Parameters
$namespace : string
 

_getAllCustomMetadataKeys()

Get all custom metadata keys

_getStringValue()

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

Get a string value from the info dictionary.

Parameters
$name : string
 
$encoding : string
 

_setStringValue()

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

Set a string value in the info dictionary.

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

_syncAuthor()

protected void SetaPDF_Core_Document_Info::_syncAuthor ( void )

Syncs author with XMP metadata package.

_syncCreationDate()

Syncs creation date with XMP metadata package.

_syncCreator()

protected void SetaPDF_Core_Document_Info::_syncCreator ( void )

Syncs creator with XMP metadata package.

_syncCustomMetadata()

public void SetaPDF_Core_Document_Info::_syncCustomMetadata ( string $name )

Syncs custom metadata with the XMP metadata package.

Parameters
$name : string

The name of the custom metadata

_syncKeywords()

protected void SetaPDF_Core_Document_Info::_syncKeywords ( void )

Syncs keywords with XMP metadata package.

_syncModDate()

protected void SetaPDF_Core_Document_Info::_syncModDate ( void )

Syncs modification date with XMP metadata package.

_syncProducer()

protected void SetaPDF_Core_Document_Info::_syncProducer ( void )

Syncs producer with XMP metadata package.

_syncSubject()

protected void SetaPDF_Core_Document_Info::_syncSubject ( void )

Syncs subject with XMP metadata package.

_syncTitle()

Syncs title with XMP metadata package.

_syncTrapped()

protected void SetaPDF_Core_Document_Info::_syncTrapped ( void )

Syncs the XMP metadata package

cleanUp()

public void SetaPDF_Core_Document_Info::cleanUp ( void )

Release memory.

getAll()

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

Get all data from the info dictionary.

Parameters
$encoding : string

The output encoding

Return Values

An key/value array of all metadata.

getAllCustomMetadata()

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

Get all custom metadata.

Parameters
$encoding : string

The output encoding

getAuthor()

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

Get the name of the person who created the document.

Parameters
$encoding : string

The output encoding

getCreationDate()

public null|string|SetaPDF_Core_DataStructure_Date SetaPDF_Core_Document_Info::getCreationDate ( [ boolean $asString = true ] )

Get the date and time the document was created.

Parameters
$asString : boolean
 

getCreator()

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

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

Parameters
$encoding : string

The output encoding

getCustomMetadata()

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

Get a custom metadata value.

Parameters
$name : string

The name of the custom metadata value

$encoding : string

The output encoding

getDictionary()

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

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

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

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

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

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

Parameters
$encoding : string

The output encoding.

getSubject()

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

Get the subject of the document.

Parameters
$encoding : string

The output encoding

getSyncMetadata()

Gets whether XMP metadata should be synced automatically.

getTitle()

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

Get the document's title.

Parameters
$encoding : string

The output encoding

getTrapped()

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

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 void SetaPDF_Core_Document_Info::setAll ( array $data [, string $encoding = 'UTF-8' ] )

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

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

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

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

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

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

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

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

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

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