forked from zendframework/zendframework
-
Notifications
You must be signed in to change notification settings - Fork 1
/
generate-metafiles.php
executable file
·38 lines (26 loc) · 1.17 KB
/
generate-metafiles.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
require_once dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'Bootstrap.php';
use DateTime;
use Zend\Service\LiveDocx\MailMerge;
$mailMerge = new MailMerge();
$mailMerge->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME)
->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD);
$mailMerge->setLocalTemplate('template.docx');
$date = new DateTime();
$mailMerge->setFieldValue('software', 'Magic Graphical Compression Suite v1.9')
->setFieldValue('licensee', 'Henry Döner-Meyer')
->setFieldValue('company', 'Megasoft Co-operation')
->setFieldValue('date', $date->format('Y-m-d'))
->setFieldValue('time', $date->format('H:i:s'))
->setFieldValue('city', 'Bremen')
->setFieldValue('country', 'Germany');
$mailMerge->createDocument();
// Get all metafiles
$metaFiles = $mailMerge->getAllMetafiles();
// Get just metafiles in specified range
//$metaFiles = $mailMerge->getMetafiles(1, 2); // fromPage, toPage
foreach ($metaFiles as $pageNumber => $metaFileData) {
$filename = sprintf('document-page-%d.wmf', $pageNumber);
file_put_contents($filename, $metaFileData);
}
unset($mailMerge);