generate-document.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. require_once dirname(__FILE__) . '/../../common.php';
  3. $phpLiveDocx = new Zend_Service_LiveDocx_MailMerge();
  4. // Set WSDL of your premium service server
  5. $phpLiveDocx->setWsdl('https://api.example.com/1.2/mailmerge.asmx?WSDL');
  6. $phpLiveDocx->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME)
  7. ->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD);
  8. $phpLiveDocx->setLocalTemplate('template.docx');
  9. $phpLiveDocx->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. $phpLiveDocx->setDocumentPassword('aaaaaaaaaa');
  18. // Available on premium service only
  19. $phpLiveDocx->setDocumentAccessPermissions(
  20. array(
  21. 'AllowHighLevelPrinting' , // getDocumentAccessOptions() returns
  22. 'AllowExtractContents' // array of permitted values
  23. ),
  24. 'myDocumentAccessPassword'
  25. );
  26. $phpLiveDocx->createDocument();
  27. $document = $phpLiveDocx->retrieveDocument('pdf');
  28. file_put_contents('document.pdf', $document);
  29. unset($phpLiveDocx);