generate-bitmaps.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. #!/usr/bin/php
  2. <?php
  3. require_once dirname(__FILE__) . '/../../common.php';
  4. $phpLiveDocx = new Zend_Service_LiveDocx_MailMerge();
  5. $phpLiveDocx->setUsername(Demos_Zend_Service_LiveDocx_Helper::USERNAME)
  6. ->setPassword(Demos_Zend_Service_LiveDocx_Helper::PASSWORD);
  7. $phpLiveDocx->setLocalTemplate('template.docx');
  8. $phpLiveDocx->assign('software', 'Magic Graphical Compression Suite v1.9')
  9. ->assign('licensee', 'Daï Lemaitre')
  10. ->assign('company', 'Megasoft Co-operation')
  11. ->assign('date', Zend_Date::now()->toString(Zend_Date::DATE_LONG))
  12. ->assign('time', Zend_Date::now()->toString(Zend_Date::TIME_LONG))
  13. ->assign('city', 'Lyon')
  14. ->assign('country', 'France');
  15. $phpLiveDocx->createDocument();
  16. // Get all bitmaps
  17. $bitmaps = $phpLiveDocx->getAllBitmaps(100, 'png'); // zoomFactor, format
  18. // Get just bitmaps in specified range
  19. //$bitmaps = $phpLiveDocx->getBitmaps(2, 2, 100, 'png'); // fromPage, toPage, zoomFactor, format
  20. foreach ($bitmaps as $pageNumber => $bitmapData) {
  21. $filename = sprintf('document-page-%d.png', $pageNumber);
  22. file_put_contents($filename, $bitmapData);
  23. }
  24. unset($phpLiveDocx);