Zend_Pdf-Create.xml 2.6 KB

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