2
0

Zend_Pdf-Create.xml 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Reviewed: no -->
  3. <sect1 id="zend.pdf.create">
  4. <title>Creating and Loading PDF Documents</title>
  5. <para>
  6. The <classname>Zend_Pdf</classname> class represents <acronym>PDF</acronym> documents and
  7. provides document-level operations.
  8. </para>
  9. <para>
  10. To create a new document, a new <classname>Zend_Pdf</classname> object should first be
  11. created.
  12. </para>
  13. <para>
  14. <classname>Zend_Pdf</classname> class also provides two static methods to load an existing
  15. <acronym>PDF</acronym> document. These are the <methodname>Zend_Pdf::load()</methodname> and
  16. <methodname>Zend_Pdf::parse()</methodname> methods. Both of them return
  17. <classname>Zend_Pdf</classname> objects as a result or throw an exception if an error
  18. occurs.
  19. </para>
  20. <example id="zend.pdf.create.example-1">
  21. <title>Create new or load existing PDF document</title>
  22. <programlisting language="php"><![CDATA[
  23. ...
  24. // Create a new PDF document
  25. $pdf1 = new Zend_Pdf();
  26. // Load a PDF document from a file
  27. $pdf2 = Zend_Pdf::load($fileName);
  28. // Load a PDF document from a string
  29. $pdf3 = Zend_Pdf::parse($pdfString);
  30. ...
  31. ]]></programlisting>
  32. </example>
  33. <para>
  34. The <acronym>PDF</acronym> file format supports incremental document update. Thus each time
  35. a document is updated, then a new revision of the document is created.
  36. <classname>Zend_Pdf</classname> component supports the retrieval of a specified revision.
  37. </para>
  38. <para>
  39. A revision can be specified as a second parameter to the
  40. <methodname>Zend_Pdf::load()</methodname> and <methodname>Zend_Pdf::parse()</methodname>
  41. methods or requested by calling the <methodname>Zend_Pdf::rollback()</methodname> method.
  42. <footnote>
  43. <para>
  44. <methodname>Zend_Pdf::rollback()</methodname> method must be invoked before any
  45. changes are applied to the document, otherwise the behavior is not defined.
  46. </para>
  47. </footnote>
  48. call.
  49. </para>
  50. <example id="zend.pdf.create.example-2">
  51. <title>Requesting Specific Revisions of a PDF Document</title>
  52. <programlisting language="php"><![CDATA[
  53. ...
  54. // Load the previous revision of the PDF document
  55. $pdf1 = Zend_Pdf::load($fileName, 1);
  56. // Load the previous revision of the PDF document
  57. $pdf2 = Zend_Pdf::parse($pdfString, 1);
  58. // Load the first revision of the PDF document
  59. $pdf3 = Zend_Pdf::load($fileName);
  60. $revisions = $pdf3->revisions();
  61. $pdf3->rollback($revisions - 1);
  62. ...
  63. ]]></programlisting>
  64. </example>
  65. </sect1>
  66. <!--
  67. vim:se ts=4 sw=4 et:
  68. -->