예제 #1
0
<?php

include_once realpath('../../../../Bootstrap.php');
use ZendService\LiveDocx\DemoHelper as Helper;
use ZendService\LiveDocx\MailMerge;
$mailMerge = new MailMerge();
$mailMerge->setUsername(DEMOS_ZENDSERVICE_LIVEDOCX_FREE_USERNAME)->setPassword(DEMOS_ZENDSERVICE_LIVEDOCX_FREE_PASSWORD)->setService(MailMerge::SERVICE_FREE);
// for LiveDocx Premium, use MailMerge::SERVICE_PREMIUM
/**
 * Image Source:
 * iStock_000003413016Medium_business-man-with-hands-up.jpg
 */
$photoFilename = __DIR__ . '/dailemaitre.jpg';
$photoFile = basename($photoFilename);
if (!$mailMerge->imageExists($photoFile)) {
    // pass image file *without* path
    $mailMerge->uploadImage($photoFilename);
    // pass image file *with* path
}
$mailMerge->setLocalTemplate('template.docx');
$mailMerge->assign('name', 'Daï Lemaitre')->assign('company', 'Megasoft Co-operation')->assign('date', Helper::currentDate())->assign('image:photo', $photoFile);
// pass image file *without* path
$mailMerge->createDocument();
$document = $mailMerge->retrieveDocument('pdf');
file_put_contents('document.pdf', $document);
$mailMerge->deleteImage($photoFilename);
unset($mailMerge);
예제 #2
0
<?php

include_once realpath('../../../../Bootstrap.php');
use ZendService\LiveDocx\DemoHelper as Helper;
use ZendService\LiveDocx\MailMerge;
Helper::printLine(PHP_EOL . 'Checking For Remotely Stored Images' . PHP_EOL . PHP_EOL);
$mailMerge = new MailMerge();
$mailMerge->setUsername(DEMOS_ZENDSERVICE_LIVEDOCX_FREE_USERNAME)->setPassword(DEMOS_ZENDSERVICE_LIVEDOCX_FREE_PASSWORD)->setService(MailMerge::SERVICE_FREE);
// for LiveDocx Premium, use MailMerge::SERVICE_PREMIUM
print 'Checking whether an image is available... ';
if (true === $mailMerge->imageExists('image-01.png')) {
    print 'EXISTS. ';
} else {
    print 'DOES NOT EXIST. ';
}
print 'DONE' . PHP_EOL;
print PHP_EOL;
unset($mailMerge);