Zend_Pdf-Properties.xml 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Reviewed: no -->
  3. <sect1 id="zend.pdf.info">
  4. <!-- @todo review and revise upon completion of refactoring -->
  5. <title>Document Info and Metadata</title>
  6. <para>
  7. A <acronym>PDF</acronym> document may include general information such as the document's
  8. title, author, and creation and modification dates.
  9. </para>
  10. <para>
  11. Historically this information is stored using special Info structure. This structure
  12. is available for read and writing as an associative array using
  13. <property>properties</property> public property of <classname>Zend_Pdf</classname> objects:
  14. </para>
  15. <programlisting language="php"><![CDATA[
  16. $pdf = Zend_Pdf::load($pdfPath);
  17. echo $pdf->properties['Title'] . "\n";
  18. echo $pdf->properties['Author'] . "\n";
  19. $pdf->properties['Title'] = 'New Title.';
  20. $pdf->save($pdfPath);
  21. ]]></programlisting>
  22. <para>
  23. The following keys are defined by <acronym>PDF</acronym> v1.4 (Acrobat 5) standard:
  24. <itemizedlist>
  25. <listitem>
  26. <para>
  27. <emphasis>Title</emphasis> - string, optional, the document's title.
  28. </para>
  29. </listitem>
  30. <listitem>
  31. <para>
  32. <emphasis>Author</emphasis> - string, optional, the name of the person who
  33. created the document.
  34. </para>
  35. </listitem>
  36. <listitem>
  37. <para>
  38. <emphasis>Subject</emphasis> - string, optional, the subject of the document.
  39. </para>
  40. </listitem>
  41. <listitem>
  42. <para>
  43. <emphasis>Keywords</emphasis> - string, optional, keywords associated with the
  44. document.
  45. </para>
  46. </listitem>
  47. <listitem>
  48. <para>
  49. <emphasis>Creator</emphasis> - string, optional, if the document was converted
  50. to <acronym>PDF</acronym> from another format, the name of the application (for
  51. example, Adobe FrameMaker®) that created the original document from which it was
  52. converted.
  53. </para>
  54. </listitem>
  55. <listitem>
  56. <para>
  57. <emphasis>Producer</emphasis> - string, optional, if the document was converted
  58. to <acronym>PDF</acronym> from another format, the name of the application (for
  59. example, Acrobat Distiller) that converted it to <acronym>PDF</acronym>..
  60. </para>
  61. </listitem>
  62. <listitem>
  63. <para>
  64. <emphasis>CreationDate</emphasis> - string, optional, the date and time the
  65. document was created, in the following form: "D:YYYYMMDDHHmmSSOHH'mm'", where:
  66. <itemizedlist>
  67. <listitem>
  68. <para>
  69. <emphasis>YYYY</emphasis> is the year.
  70. </para>
  71. </listitem>
  72. <listitem>
  73. <para>
  74. <emphasis>MM</emphasis> is the month.
  75. </para>
  76. </listitem>
  77. <listitem>
  78. <para>
  79. <emphasis>DD</emphasis> is the day (01–31).
  80. </para>
  81. </listitem>
  82. <listitem>
  83. <para>
  84. <emphasis>HH</emphasis> is the hour (00–23).
  85. </para>
  86. </listitem>
  87. <listitem>
  88. <para>
  89. <emphasis>mm</emphasis>is the minute (00–59).
  90. </para>
  91. </listitem>
  92. <listitem>
  93. <para>
  94. <emphasis>SS</emphasis> is the second (00–59).
  95. </para>
  96. </listitem>
  97. <listitem>
  98. <para>
  99. <emphasis>O</emphasis> is the relationship of local time to
  100. Universal Time (UT), denoted by one of the characters +, −, or Z
  101. (see below).
  102. </para>
  103. </listitem>
  104. <listitem>
  105. <para>
  106. <emphasis>HH</emphasis> followed by ' is the absolute value of the
  107. offset from UT in hours (00–23).
  108. </para>
  109. </listitem>
  110. <listitem>
  111. <para>
  112. <emphasis>mm</emphasis> followed by ' is the absolute value of the
  113. offset from UT in minutes (00–59).
  114. </para>
  115. </listitem>
  116. </itemizedlist>
  117. The apostrophe character (') after HH and mm is part of the syntax. All fields
  118. after the year are optional. (The prefix D:, although also optional, is strongly
  119. recommended.) The default values for MM and DD are both 01; all other numerical
  120. fields default to zero values. A plus sign (+) as the value of the O field
  121. signifies that local time is later than UT, a minus sign (−) that local time is
  122. earlier than UT, and the letter Z that local time is equal to UT. If no UT
  123. information is specified, the relationship of the specified time to UT is
  124. considered to be unknown. Whether or not the time zone is known, the rest of the
  125. date should be specified in local time.
  126. </para>
  127. <para>
  128. For example, December 23, 1998, at 7:52 PM, U.S. Pacific Standard Time, is
  129. represented by the string "D:199812231952−08'00'".
  130. </para>
  131. </listitem>
  132. <listitem>
  133. <para>
  134. <emphasis>ModDate</emphasis> - string, optional, the date and time the document
  135. was most recently modified, in the same form as
  136. <emphasis>CreationDate</emphasis>.
  137. </para>
  138. </listitem>
  139. <listitem>
  140. <para>
  141. <emphasis>Trapped</emphasis> - boolean, optional, indicates whether the document
  142. has been modified to include trapping information.
  143. <itemizedlist>
  144. <listitem>
  145. <para>
  146. <emphasis><constant>TRUE</constant></emphasis> - The document has
  147. been fully trapped; no further trapping is needed.
  148. </para>
  149. </listitem>
  150. <listitem>
  151. <para>
  152. <emphasis><constant>FALSE</constant></emphasis> - The document has
  153. not yet been trapped; any desired trapping must still be done.
  154. </para>
  155. </listitem>
  156. <listitem>
  157. <para>
  158. <emphasis><constant>NULL</constant></emphasis> - Either it is
  159. unknown whether the document has been trapped or it has been partly
  160. but not yet fully trapped; some additional trapping may still be
  161. needed.
  162. </para>
  163. </listitem>
  164. </itemizedlist>
  165. </para>
  166. </listitem>
  167. </itemizedlist>
  168. </para>
  169. <para>
  170. Since <acronym>PDF</acronym> v 1.6 metadata can be stored in the special
  171. <acronym>XML</acronym> document attached to the <acronym>PDF</acronym> (XMP - <ulink
  172. url="http://www.adobe.com/products/xmp/">Extensible Metadata Platform</ulink>).
  173. </para>
  174. <para>
  175. This <acronym>XML</acronym> document can be retrieved and attached to the PDF with
  176. <methodname>Zend_Pdf::getMetadata()</methodname> and
  177. <methodname>Zend_Pdf::setMetadata($metadata)</methodname> methods:
  178. </para>
  179. <programlisting language="php"><![CDATA[
  180. $pdf = Zend_Pdf::load($pdfPath);
  181. $metadata = $pdf->getMetadata();
  182. $metadataDOM = new DOMDocument();
  183. $metadataDOM->loadXML($metadata);
  184. $xpath = new DOMXPath($metadataDOM);
  185. $pdfPreffixNamespaceURI = $xpath->query('/rdf:RDF/rdf:Description')
  186. ->item(0)
  187. ->lookupNamespaceURI('pdf');
  188. $xpath->registerNamespace('pdf', $pdfPreffixNamespaceURI);
  189. $titleNode = $xpath->query('/rdf:RDF/rdf:Description/pdf:Title')->item(0);
  190. $title = $titleNode->nodeValue;
  191. ...
  192. $titleNode->nodeValue = 'New title';
  193. $pdf->setMetadata($metadataDOM->saveXML());
  194. $pdf->save($pdfPath);
  195. ]]></programlisting>
  196. <para>
  197. Common document properties are duplicated in the Info structure and Metadata document (if
  198. presented). It's user application responsibility now to keep them synchronized.
  199. </para>
  200. </sect1>
  201. <!--
  202. vim:se ts=4 sw=4 et:
  203. -->