2
0

Zend_Pdf-Properties.xml 8.9 KB

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