convert-document.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. require_once dirname(__FILE__) . '/../../common.php';
  3. /**
  4. * Converting documents between supported formats
  5. *
  6. * The primary goal of Zend_Service_LiveDocx_MailMerge is to populate templates
  7. * with textual data to generate word processing documents. It can, however,
  8. * also be used to convert word processing documents between supported formats.
  9. *
  10. * For a list of supported file formats see: http://is.gd/6YKDu
  11. *
  12. * In this demo application, the file 'document.doc' is converted to 'document.pdf'
  13. *
  14. * In a future version of the LiveDocx service, a converter component will be
  15. * made available.
  16. */
  17. $mailMerge = new Zend_Service_LiveDocx_MailMerge();
  18. $mailMerge->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME)
  19. ->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD);
  20. $mailMerge->setLocalTemplate('document.doc');
  21. $mailMerge->assign('dummyFieldName', 'dummyFieldValue'); // necessary as of LiveDocx 1.2
  22. $mailMerge->createDocument();
  23. $document = $mailMerge->retrieveDocument('pdf');
  24. file_put_contents('document.pdf', $document);
  25. unset($mailMerge);