generate-bitmaps.php 1.2 KB

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