/demos/Zend/Service/LiveDocx/MailMerge/pdf-security/generate-document.php

https://github.com/decaoz/zf1 · PHP · 42 lines · 26 code · 13 blank · 3 comment · 0 complexity · d513cf9988950c4adc47fb1cd11d3c03 MD5 · raw file

  1. <?php
  2. require_once dirname(__FILE__) . '/../../common.php';
  3. $mailMerge = new Zend_Service_LiveDocx_MailMerge();
  4. // Set WSDL of your premium service server
  5. $mailMerge->setWsdl('https://api.example.com/1.2/mailmerge.asmx?WSDL');
  6. $mailMerge->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME)
  7. ->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD);
  8. $mailMerge->setLocalTemplate('template.docx');
  9. $mailMerge->assign('software', 'Magic Graphical Compression Suite v1.9')
  10. ->assign('licensee', 'Henry Döner-Meyer')
  11. ->assign('company', 'Co-Operation')
  12. ->assign('date', Zend_Date::now()->toString(Zend_Date::DATE_LONG))
  13. ->assign('time', Zend_Date::now()->toString(Zend_Date::TIME_LONG))
  14. ->assign('city', 'Berlin')
  15. ->assign('country', 'Germany');
  16. // Available on premium service only
  17. $mailMerge->setDocumentPassword('aaaaaaaaaa');
  18. // Available on premium service only
  19. $mailMerge->setDocumentAccessPermissions(
  20. array(
  21. 'AllowHighLevelPrinting' , // getDocumentAccessOptions() returns
  22. 'AllowExtractContents' // array of permitted values
  23. ),
  24. 'myDocumentAccessPassword'
  25. );
  26. $mailMerge->createDocument();
  27. $document = $mailMerge->retrieveDocument('pdf');
  28. file_put_contents('document.pdf', $document);
  29. unset($mailMerge);