1 <?xml version="1.0" encoding="UTF-8"?>
3 <sect1 id="zend.pdf.info">
4 <!-- @todo review and revise upon completion of refactoring -->
5 <title>Document Info and Metadata</title>
8 A <acronym>PDF</acronym> document may include general information such as the document's
9 title, author, and creation and modification dates.
13 Historically this information is stored using special Info structure. This structure
14 is available for read and writing as an associative array using <code>properties</code>
15 public property of <classname>Zend_Pdf</classname> objects:
17 <programlisting language="php"><![CDATA[
18 $pdf = Zend_Pdf::load($pdfPath);
20 echo $pdf->properties['Title'] . "\n";
21 echo $pdf->properties['Author'] . "\n";
23 $pdf->properties['Title'] = 'New Title.';
29 The following keys are defined by <acronym>PDF</acronym> v1.4 (Acrobat 5) standard:
34 <emphasis>Title</emphasis> - string, optional, the document's title.
40 <emphasis>Author</emphasis> - string, optional, the name of the person who
47 <emphasis>Subject</emphasis> - string, optional, the subject of the document.
53 <emphasis>Keywords</emphasis> - string, optional, keywords associated with the
60 <emphasis>Creator</emphasis> - string, optional, if the document was converted
61 to <acronym>PDF</acronym> from another format, the name of the application (for
62 example, Adobe FrameMaker®) that created the original document from which it was
69 <emphasis>Producer</emphasis> - string, optional, if the document was converted
70 to <acronym>PDF</acronym> from another format, the name of the application (for
71 example, Acrobat Distiller) that converted it to <acronym>PDF</acronym>..
77 <emphasis>CreationDate</emphasis> - string, optional, the date and time the
78 document was created, in the following form: "D:YYYYMMDDHHmmSSOHH'mm'", where:
83 <emphasis>YYYY</emphasis> is the year.
89 <emphasis>MM</emphasis> is the month.
95 <emphasis>DD</emphasis> is the day (01–31).
101 <emphasis>HH</emphasis> is the hour (00–23).
107 <emphasis>mm</emphasis>is the minute (00–59).
113 <emphasis>SS</emphasis> is the second (00–59).
119 <emphasis>O</emphasis> is the relationship of local time to
120 Universal Time (UT), denoted by one of the characters +, −, or Z
127 <emphasis>HH</emphasis> followed by ' is the absolute value of the
128 offset from UT in hours (00–23).
134 <emphasis>mm</emphasis> followed by ' is the absolute value of the
135 offset from UT in minutes (00–59).
140 The apostrophe character (') after HH and mm is part of the syntax. All fields
141 after the year are optional. (The prefix D:, although also optional, is strongly
142 recommended.) The default values for MM and DD are both 01; all other numerical
143 fields default to zero values. A plus sign (+) as the value of the O field
144 signifies that local time is later than UT, a minus sign (−) that local time is
145 earlier than UT, and the letter Z that local time is equal to UT. If no UT
146 information is specified, the relationship of the specified time to UT is
147 considered to be unknown. Whether or not the time zone is known, the rest of the
148 date should be specified in local time.
152 For example, December 23, 1998, at 7:52 PM, U.S. Pacific Standard Time, is
153 represented by the string "D:199812231952−08'00'".
159 <emphasis>ModDate</emphasis> - string, optional, the date and time the document
160 was most recently modified, in the same form as
161 <emphasis>CreationDate</emphasis>.
167 <emphasis>Trapped</emphasis> - boolean, optional, indicates whether the document
168 has been modified to include trapping information.
173 <emphasis><constant>TRUE</constant></emphasis> - The document has
174 been fully trapped; no further trapping is needed.
180 <emphasis><constant>FALSE</constant></emphasis> - The document has
181 not yet been trapped; any desired trapping must still be done.
187 <emphasis><constant>NULL</constant></emphasis> - Either it is
188 unknown whether the document has been trapped or it has been partly
189 but not yet fully trapped; some additional trapping may still be
200 Since <acronym>PDF</acronym> v 1.6 metadata can be stored in the special
201 <acronym>XML</acronym> document attached to the <acronym>PDF</acronym> (XMP - <ulink
202 url="http://www.adobe.com/products/xmp/">Extensible Metadata Platform</ulink>).
206 This XML document can be retrieved and attached to the PDF with
207 <methodname>Zend_Pdf::getMetadata()</methodname> and
208 <methodname>Zend_Pdf::setMetadata($metadata)</methodname> methods:
210 <programlisting language="php"><![CDATA[
211 $pdf = Zend_Pdf::load($pdfPath);
212 $metadata = $pdf->getMetadata();
213 $metadataDOM = new DOMDocument();
214 $metadataDOM->loadXML($metadata);
216 $xpath = new DOMXPath($metadataDOM);
217 $pdfPreffixNamespaceURI = $xpath->query('/rdf:RDF/rdf:Description')
219 ->lookupNamespaceURI('pdf');
220 $xpath->registerNamespace('pdf', $pdfPreffixNamespaceURI);
222 $titleNode = $xpath->query('/rdf:RDF/rdf:Description/pdf:Title')->item(0);
223 $title = $titleNode->nodeValue;
226 $titleNode->nodeValue = 'New title';
227 $pdf->setMetadata($metadataDOM->saveXML());
228 $pdf->save($pdfPath);
233 Common document properties are duplicated in the Info structure and Metadata document (if
234 presented). It's user application responsibility now to keep them synchronized.