PageRenderTime 21ms CodeModel.GetById 10ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 1ms

/demos/Zend/Service/LiveDocx/MailMerge/metafiles/generate-metafiles.php

https://github.com/decaoz/zf1
PHP | 34 lines | 20 code | 11 blank | 3 comment | 0 complexity | 7c6ce9d84d39d02fd0a81f9ce53381d2 MD5 | raw file
 1<?php
 2
 3require_once dirname(__FILE__) . '/../../common.php';
 4
 5
 6$mailMerge = new Zend_Service_LiveDocx_MailMerge();
 7
 8$mailMerge->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME)
 9          ->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD);
10
11$mailMerge->setLocalTemplate('template.docx');
12            
13$mailMerge->setFieldValue('software', 'Magic Graphical Compression Suite v1.9')
14          ->setFieldValue('licensee', 'Henry Döner-Meyer')
15          ->setFieldValue('company',  'Megasoft Co-operation')
16          ->setFieldValue('date',     Zend_Date::now()->toString(Zend_Date::DATE_LONG))
17          ->setFieldValue('time',     Zend_Date::now()->toString(Zend_Date::TIME_LONG))
18          ->setFieldValue('city',     'Bremen')
19          ->setFieldValue('country',  'Germany');
20
21$mailMerge->createDocument();
22
23// Get all metafiles
24$metaFiles = $mailMerge->getAllMetafiles();
25
26// Get just metafiles in specified range
27//$metaFiles = $mailMerge->getMetafiles(1, 2);    // fromPage, toPage
28
29foreach ($metaFiles as $pageNumber => $metaFileData) {
30    $filename = sprintf('document-page-%d.wmf', $pageNumber);
31    file_put_contents($filename, $metaFileData);
32}
33
34unset($mailMerge);