Exemplo n.º 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);
Exemplo n.º 2
0
<?php

include_once realpath('../../../../Bootstrap.php');
use ZendService\LiveDocx\DemoHelper as Helper;
use ZendService\LiveDocx\MailMerge;
Helper::printLine(PHP_EOL . 'Uploading Locally Stored Templates to Server' . 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 'Uploading template... ';
$mailMerge->uploadTemplate('template-1.docx');
print 'DONE.' . PHP_EOL;
print 'Uploading template... ';
$mailMerge->uploadTemplate('template-2.docx');
print 'DONE.' . PHP_EOL;
print PHP_EOL;
unset($mailMerge);
$writerQueue = new SplPriorityQueue();
$writerQueue->insert(new Writer('php://stdout'), 1);
$logger = new Logger();
$logger->setWriters($writerQueue);
// -----------------------------------------------------------------------------
// Create temporary directory
$tempDirectory = sys_get_temp_dir() . DIRECTORY_SEPARATOR . md5(rand(1, 10000) . __FILE__);
if (is_dir($tempDirectory)) {
    recursiveRemoveDirectory($tempDirectory);
}
$logger->log(Logger::INFO, sprintf('Making temporary directory %s.', $tempDirectory));
mkdir($tempDirectory);
// -----------------------------------------------------------------------------
// Generate temporary documents
$tempFilenames = array();
$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;
$mailMerge->setLocalTemplate('template.docx');
for ($iteration = 1; $iteration <= $iterations; $iteration++) {
    $tempFilename = sprintf('%s%s%010s.pdf', $tempDirectory, DIRECTORY_SEPARATOR, $iteration);
    $tempFilenames[] = $tempFilename;
    $mailMerge->assign('software', randomString())->assign('licensee', randomString())->assign('company', randomString())->assign('date', Helper::currentDate())->assign('time', Helper::currentTime())->assign('city', randomString())->assign('country', randomString());
    $mailMerge->createDocument();
    file_put_contents($tempFilename, $mailMerge->retrieveDocument('pdf'));
    $logger->log(Logger::INFO, sprintf('Generating temporary document %s.', $tempFilename));
}
unset($mailMerge);
// -----------------------------------------------------------------------------
// Concatenate temporary documents and write output document
$outputFilename = __DIR__ . DIRECTORY_SEPARATOR . 'document-concat.pdf';
Exemplo n.º 4
0
<?php

include_once realpath('../../../../Bootstrap.php');
use ZendService\LiveDocx\DemoHelper as Helper;
use ZendService\LiveDocx\MailMerge;
Helper::printLine(PHP_EOL . 'Deleting All Remotely Stored Templates' . 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
$counter = 1;
foreach ($mailMerge->listTemplates() as $result) {
    printf('%d) %s', $counter, $result['filename']);
    $mailMerge->deleteTemplate($result['filename']);
    print ' - DELETED.' . PHP_EOL;
    $counter++;
}
print PHP_EOL;
unset($mailMerge);
Exemplo n.º 5
0
<?php

include_once realpath('../../../../Bootstrap.php');
use ZendService\LiveDocx\DemoHelper as Helper;
use ZendService\LiveDocx\MailMerge;
Helper::printLine(PHP_EOL . 'Remotely Stored Images' . PHP_EOL . PHP_EOL . 'The following images are currently stored on the LiveDocx server:' . 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 Helper::listDecorator($mailMerge->listImages());
unset($mailMerge);
<?php

include_once realpath('../../../../Bootstrap.php');
use ZendService\LiveDocx\DemoHelper as Helper;
use ZendService\LiveDocx\MailMerge;
Helper::printLine(PHP_EOL . 'Template, Document and Image Formats' . PHP_EOL . PHP_EOL . 'The following formats are supported by LiveDocx:' . 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
printf("Supported TEMPLATE file formats (input)  : %s%s", Helper::arrayDecorator($mailMerge->getTemplateFormats()), PHP_EOL);
printf("Supported DOCUMENT file formats (output) : %s%s", Helper::arrayDecorator($mailMerge->getDocumentFormats()), PHP_EOL);
printf("Supported IMAGE file formats (output)    : %s%s", Helper::arrayDecorator($mailMerge->getImageExportFormats()), PHP_EOL);
print PHP_EOL;
unset($mailMerge);
Exemplo n.º 7
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);
Exemplo n.º 8
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
Helper::printLine(PHP_EOL . 'Supported Fonts' . PHP_EOL . PHP_EOL . 'The following fonts are installed on the backend server and may be used in templates. Fonts used in templates, which are NOT listed below, will be substituted. If you would like to use a font, which is not installed on the backend server, please contact your LiveDocx provider.' . PHP_EOL . PHP_EOL . Helper::arrayDecorator($mailMerge->getFontNames()) . PHP_EOL . PHP_EOL);
unset($mailMerge);
Exemplo n.º 9
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
$mailMerge->setLocalTemplate('template.doc');
$mailMerge->assign('customer_number', sprintf("#%'10s", rand(0, 1000000000)))->assign('invoice_number', sprintf("#%'10s", rand(0, 1000000000)))->assign('account_number', sprintf("#%'10s", rand(0, 1000000000)));
$billData = array('phone' => '+22 (0)333 444 555', 'date' => Helper::currentDate(), 'name' => 'James Henry Brown', 'service_phone' => '+22 (0)333 444 559', 'service_fax' => '+22 (0)333 444 558', 'month' => Helper::currentMonthYear(), 'monthly_fee' => '15.00', 'total_net' => '19.60', 'tax' => '19.00', 'tax_value' => '3.72', 'total' => '23.32');
$mailMerge->assign($billData);
$billConnections = array(array('connection_number' => '+11 (0)222 333 441', 'connection_duration' => '00:01:01', 'fee' => '1.15'), array('connection_number' => '+11 (0)222 333 442', 'connection_duration' => '00:01:02', 'fee' => '1.15'), array('connection_number' => '+11 (0)222 333 443', 'connection_duration' => '00:01:03', 'fee' => '1.15'), array('connection_number' => '+11 (0)222 333 444', 'connection_duration' => '00:01:04', 'fee' => '1.15'));
$mailMerge->assign('connection', $billConnections);
$mailMerge->createDocument();
$document = $mailMerge->retrieveDocument('pdf');
unset($mailMerge);
file_put_contents('document.pdf', $document);
Exemplo n.º 10
0
<?php

include_once realpath('../../../../Bootstrap.php');
use ZendService\LiveDocx\DemoHelper as Helper;
use ZendService\LiveDocx\MailMerge;
Helper::printLine(PHP_EOL . 'Uploading Locally Stored Images to Server' . 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 'Uploading image... ';
$mailMerge->uploadImage('image-01.png');
print 'DONE.' . PHP_EOL;
print 'Uploading image... ';
$mailMerge->uploadImage('image-02.png');
print 'DONE.' . PHP_EOL;
print PHP_EOL;
unset($mailMerge);
<?php

include_once realpath('../../../../Bootstrap.php');
use ZendService\LiveDocx\MailMerge;
use ZendService\LiveDocx\DemoHelper as Helper;
Helper::printLine(PHP_EOL . 'Document Access Options' . PHP_EOL . PHP_EOL . 'Documents can be protected using one or more document access option:' . PHP_EOL . PHP_EOL);
$mailMerge = new MailMerge();
$mailMerge->setUsername(DEMOS_ZENDSERVICE_LIVEDOCX_PREMIUM_USERNAME)->setPassword(DEMOS_ZENDSERVICE_LIVEDOCX_PREMIUM_PASSWORD)->setService(MailMerge::SERVICE_PREMIUM);
Helper::printLine(implode(', ', $mailMerge->getDocumentAccessOptions()) . '.' . PHP_EOL . PHP_EOL);
unset($mailMerge);
Exemplo n.º 12
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 Templates' . 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 a template is available... ';
if (true === $mailMerge->templateExists('template-1.docx')) {
    print 'EXISTS. ';
} else {
    print 'DOES NOT EXIST. ';
}
print 'DONE' . PHP_EOL;
print PHP_EOL;
unset($mailMerge);
<?php

include_once realpath('./common.php');
/**
 * The following variables are defined in the included 'common.php' file:
 *
 * (string) $templateFilename       Main template file (one that includes subtemplates).
 * (string) $subTemplate1Filename   Subtemplate 1      (one that is included in main template).
 * (string) $subTemplate2Filename   Subtemplate 2      (one that is included in main template).
 *
 * (array)  $templateFilesnames     An array containing the above.
 */
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
// -----------------------------------------------------------------------------
foreach ($templateFilesnames as $filename) {
    if ($mailMerge->templateExists($filename)) {
        $mailMerge->deleteTemplate($filename);
    }
    $mailMerge->uploadTemplate($filename);
}
// -----------------------------------------------------------------------------
$mailMerge->setIgnoreSubTemplates(true);
// <-- Does NOT include any sub-templates.
$mailMerge->setRemoteTemplate($templateFilename);
$mailMerge->createDocument();
$document = $mailMerge->retrieveDocument('pdf');
file_put_contents('document-ignore-1.pdf', $document);
// -----------------------------------------------------------------------------
Exemplo n.º 14
0
<?php

include_once realpath('../../../../Bootstrap.php');
use ZendService\LiveDocx\DemoHelper as Helper;
use ZendService\LiveDocx\MailMerge;
Helper::printLine(PHP_EOL . 'Field and Block Field Names (merge fields)' . PHP_EOL . PHP_EOL . 'The following templates contain the listed field or block field names:' . 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
// -----------------------------------------------------------------------------
$templateName = 'template-1-text-field.docx';
$mailMerge->setLocalTemplate($templateName);
printf('Field names in %s:%s', $templateName, PHP_EOL);
$fieldNames = $mailMerge->getFieldNames();
foreach ($fieldNames as $fieldName) {
    printf('- %s%s', $fieldName, PHP_EOL);
}
// -----------------------------------------------------------------------------
$templateName = 'template-2-text-fields.doc';
$mailMerge->setLocalTemplate($templateName);
printf('%sField names in %s:%s', PHP_EOL, $templateName, PHP_EOL);
$fieldNames = $mailMerge->getFieldNames();
foreach ($fieldNames as $fieldName) {
    printf('- %s%s', $fieldName, PHP_EOL);
}
// -----------------------------------------------------------------------------
$templateName = 'template-block-fields.doc';
$mailMerge->setLocalTemplate($templateName);
printf('%sField names in %s:%s', PHP_EOL, $templateName, PHP_EOL);
$fieldNames = $mailMerge->getFieldNames();
foreach ($fieldNames as $fieldName) {
Exemplo n.º 15
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
$mailMerge->setLocalTemplate('template.docx');
$mailMerge->setFieldValue('software', 'Magic Graphical Compression Suite v1.9')->setFieldValue('licensee', 'Henry Döner-Meyer')->setFieldValue('company', 'Megasoft Co-operation')->setFieldValue('date', Helper::currentDate())->setFieldValue('time', Helper::currentTime())->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);
Exemplo n.º 16
0
     // Validate the webhook
     PodioHook::validate($_POST['hook_id'], array('code' => $_POST['code']));
 case 'item.create':
     $item = PodioItem::get($_POST['item_id']);
     $temp_array = array();
     foreach ($item->files as $fs) {
         $temp_array[] = $fs;
         if ($fs->mimetype == 'application/msword') {
             //Get file name withour ext
             $no_ext = substr($fs->name, 0, strpos($fs->name, '.'));
             //Upload file to our server
             $fl = PodioFile::get($fs->file_id);
             $fc = $fl->get_raw();
             file_put_contents($upload_path . $fs->name, $fc);
             //Part with convert files from doc(x) to pdf
             $mailMerge = new MailMerge();
             $mailMerge->setUsername($user)->setPassword($password)->setService(MailMerge::SERVICE_FREE);
             $mailMerge->setLocalTemplate($upload_path . $fs->name);
             $mailMerge->assign('software', 'Magic Graphical Compression Suite v1.9');
             $mailMerge->createDocument();
             $document = $mailMerge->retrieveDocument($need_ext);
             file_put_contents($upload_path . $no_ext . $ext_pdf, $document);
             unset($mailMerge);
             // Attached file pdf to our item
             $f = PodioFile::upload($upload_path . $no_ext . $ext_pdf, $no_ext . $ext_pdf);
             $temp_array[] = $f;
             // Removed temp files
             unlink($upload_path . $fs->name);
             unlink($upload_path . $no_ext . $ext_pdf);
         }
     }
<?php

include_once realpath('../../../../Bootstrap.php');
use ZendService\LiveDocx\DemoHelper as Helper;
use ZendService\LiveDocx\MailMerge;
Helper::printLine(PHP_EOL . 'Using LiveDocx Fully Licensed' . PHP_EOL . PHP_EOL . 'This sample application illustrates how to use the Zend Framework LiveDocx component with the LiveDocx running in your own network.' . PHP_EOL . PHP_EOL);
// -----------------------------------------------------------------------------
// Pass login credentials using set methods
$mailMerge = new MailMerge();
$mailMerge->setUsername('your-username')->setPassword('your-password')->setWsdl('http://api.example.com/2.1/mailmerge.asmx?wsdl');
// set the WSDL of your locally installed,
// LiveDocx Fully Licensed server here
$mailMerge->getTemplateFormats();
// then call methods as usual
printf('Username : %s%sPassword : %s%s    WSDL : %s%s%s', $mailMerge->getUsername(), PHP_EOL, $mailMerge->getPassword(), PHP_EOL, $mailMerge->getWsdl(), PHP_EOL, PHP_EOL);
unset($mailMerge);
// -----------------------------------------------------------------------------
// Pass login credentials using constructor
$mailMerge = new MailMerge();
$mailMerge = new MailMerge(array('username' => 'your-username', 'password' => 'your-password', 'wsdl' => 'http://api.example.com/2.1/mailmerge.asmx?wsdl'));
// set the WSDL of your
// LiveDocx Fully Licensed server here
$mailMerge->getTemplateFormats();
// then call methods as usual
printf('Username : %s%sPassword : %s%s    WSDL : %s%s%s', $mailMerge->getUsername(), PHP_EOL, $mailMerge->getPassword(), PHP_EOL, $mailMerge->getWsdl(), PHP_EOL, PHP_EOL);
unset($mailMerge);
// -----------------------------------------------------------------------------
Exemplo n.º 18
0
<?php

include_once realpath('../../../../Bootstrap.php');
use ZendService\LiveDocx\MailMerge;
use ZendService\LiveDocx\DemoHelper as Helper;
$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
$mailMerge->setLocalTemplate('template.docx');
$mailMerge->assign('software', 'Magic Graphical Compression Suite v1.9')->assign('licensee', 'Henry Döner-Meyer')->assign('company', 'Co-Operation')->assign('date', Helper::currentDate())->assign('time', Helper::currentTime())->assign('city', 'Berlin')->assign('country', 'Germany');
/**
 * ALTERNATIVE: Concatenating PDF files locally - basic
 *
 * You can also assign multiple sets of data. In this case, each set of data
 * will populate the template and the resulting document (one per set of data)
 * will be appended to the previous document. Thus, in this example, we create
 * two documents that are concatenated into one PDF file.
 *
 * NOTE: In the case that you wish to generate several thousand documents that
 *       are concatenated into one PDF, please take a look at the sample
 *       application 'generate-document-pdftk.php' in this directory.
 */
/*
$fieldValues = array (
    // set 1
    array (
        'software' => 'Magic Graphical Compression Suite v2.5',
        'licensee' => 'Henry Döner-Meyer',
        'company'  => 'Megasoft Co-Operation',
        'date'     => Helper::currentDate(),
        'time'     => Helper::currentTime(),
Exemplo n.º 19
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
$mailMerge->setLocalTemplate('template.docx');
$mailMerge->assign('software', 'Magic Graphical Compression Suite v1.9')->assign('licensee', 'Daï Lemaitre')->assign('company', 'Megasoft Co-operation')->assign('date', Helper::currentDate())->assign('time', Helper::currentTime())->assign('city', 'Lyon')->assign('country', 'France');
$mailMerge->createDocument();
// Get all bitmaps
$bitmaps = $mailMerge->getAllBitmaps(100, 'png');
// zoomFactor, format
// Get just bitmaps in specified range
//$bitmaps = $mailMerge->getBitmaps(2, 2, 100, 'png');   // fromPage, toPage, zoomFactor, format
foreach ($bitmaps as $pageNumber => $bitmapData) {
    $filename = sprintf('document-page-%d.png', $pageNumber);
    file_put_contents($filename, $bitmapData);
}
unset($mailMerge);
<?php

include_once realpath('./common.php');
/**
 * The following variables are defined in the included 'common.php' file:
 *
 * (string) $templateFilename       Main template file (one that includes subtemplates).
 * (string) $subTemplate1Filename   Subtemplate 1      (one that is included in main template).
 * (string) $subTemplate2Filename   Subtemplate 2      (one that is included in main template).
 *
 * (array)  $templateFilesnames     An array containing the above.
 */
use ZendService\LiveDocx\MailMerge;
$mailMerge = new MailMerge();
$mailMerge->setUsername(DEMOS_ZENDSERVICE_LIVEDOCX_PREMIUM_USERNAME)->setPassword(DEMOS_ZENDSERVICE_LIVEDOCX_PREMIUM_PASSWORD)->setService(MailMerge::SERVICE_PREMIUM);
// -----------------------------------------------------------------------------
foreach ($templateFilesnames as $filename) {
    if ($mailMerge->templateExists($filename)) {
        $mailMerge->deleteTemplate($filename);
    }
    $mailMerge->uploadTemplate($filename);
}
// -----------------------------------------------------------------------------
$mailMerge->setSubTemplateIgnoreList(array($subTemplate1Filename, $subTemplate2Filename));
$mailMerge->setRemoteTemplate($templateFilename);
$mailMerge->createDocument();
$document = $mailMerge->retrieveDocument('pdf');
file_put_contents('document-ignore-list-1.pdf', $document);
// -----------------------------------------------------------------------------
$mailMerge->setSubTemplateIgnoreList(array($subTemplate1Filename));
$mailMerge->setRemoteTemplate($templateFilename);
Exemplo n.º 21
0
 public function testMultiAssocArrayToArrayOfArrayOfString()
 {
     $testValues = array(array('a' => '1', 'b' => '2', 'c' => '3'), array('a' => '4', 'b' => '5', 'c' => '6'), array('a' => '7', 'b' => '8', 'c' => '9'));
     $expectedResults = array(array('a', 'b', 'c'), array('1', '2', '3'), array('4', '5', '6'), array('7', '8', '9'));
     $actualResults = MailMerge::multiAssocArrayToArrayOfArrayOfString($testValues);
     $this->assertEquals($expectedResults, $actualResults);
 }
Exemplo n.º 22
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_PREMIUM_USERNAME)->setPassword(DEMOS_ZENDSERVICE_LIVEDOCX_PREMIUM_PASSWORD)->setService(MailMerge::SERVICE_PREMIUM);
$mailMerge->setLocalTemplate('template.docx');
$mailMerge->assign('software', 'Magic Graphical Compression Suite v1.9')->assign('licensee', 'Henry Döner-Meyer')->assign('company', 'Co-Operation')->assign('date', Helper::currentDate())->assign('time', Helper::currentTime())->assign('city', 'Berlin')->assign('country', 'Germany');
// Available on premium service only
$mailMerge->setDocumentPassword('aaaaaaaaaa');
// Available on premium service only
$mailMerge->setDocumentAccessPermissions(array('AllowHighLevelPrinting', 'AllowExtractContents'), 'myDocumentAccessPassword');
$mailMerge->createDocument();
$document = $mailMerge->retrieveDocument('pdf');
file_put_contents('document.pdf', $document);
unset($mailMerge);
Exemplo n.º 23
0
}
// -----------------------------------------------------------------------------
if (defined('DEMOS_ZENDSERVICE_LIVEDOCX_PREMIUM_USERNAME') && defined('DEMOS_ZENDSERVICE_LIVEDOCX_PREMIUM_PASSWORD') && false !== DEMOS_ZENDSERVICE_LIVEDOCX_PREMIUM_USERNAME && false !== DEMOS_ZENDSERVICE_LIVEDOCX_PREMIUM_PASSWORD) {
    $result = TEST_PASS;
} else {
    $result = TEST_FAIL;
    $failed = false;
}
Helper::printLineToc($counter, 'Checking LiveDocx Premium credentials are defined', $result);
$counter++;
// -----------------------------------------------------------------------------
if (defined('DEMOS_ZENDSERVICE_LIVEDOCX_PREMIUM_USERNAME') && defined('DEMOS_ZENDSERVICE_LIVEDOCX_PREMIUM_PASSWORD') && false !== DEMOS_ZENDSERVICE_LIVEDOCX_PREMIUM_USERNAME && false !== DEMOS_ZENDSERVICE_LIVEDOCX_PREMIUM_PASSWORD) {
    $errorMessage = null;
    try {
        $microtime = microtime(true);
        $mailMerge = new MailMerge();
        $mailMerge->setUsername(DEMOS_ZENDSERVICE_LIVEDOCX_PREMIUM_USERNAME)->setPassword(DEMOS_ZENDSERVICE_LIVEDOCX_PREMIUM_PASSWORD)->setService(MailMerge::SERVICE_PREMIUM)->listTemplates();
        $duration = microtime(true) - $microtime;
        unset($mailMerge);
    } catch (Exception $e) {
        $duration = -1;
        $errorMessage = $e->getMessage();
    }
    if (is_null($errorMessage)) {
        $result = TEST_PASS;
    } else {
        $result = TEST_FAIL;
        $failed = true;
    }
    Helper::printLineToc($counter, sprintf('Logging into LiveDocx Premium (%01.2fs)', $duration), $result);
    $counter++;
Exemplo n.º 24
0
<?php

include_once realpath('../../../../Bootstrap.php');
use ZendService\LiveDocx\DemoHelper as Helper;
use ZendService\LiveDocx\MailMerge;
Helper::printLine(PHP_EOL . 'Downloading 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
$counter = 1;
foreach ($mailMerge->listImages() as $result) {
    printf('%d) %s', $counter, $result['filename']);
    $image = $mailMerge->downloadImage($result['filename']);
    file_put_contents('downloaded-' . $result['filename'], $image);
    print ' - DOWNLOADED.' . PHP_EOL;
    $counter++;
}
print PHP_EOL;
unset($mailMerge);
Exemplo n.º 25
0
<?php

include_once realpath('../../../../Bootstrap.php');
/**
 * Converting documents between supported formats
 *
 * The primary goal of the Zend Framework LiveDocx component is to populate templates
 * with textual data to generate word processing documents. It can, however,
 * also be used to convert word processing documents between supported formats.
 *
 * For a list of supported file formats see: http://is.gd/6YKDu
 *
 * In this demo application, the file 'document.doc' is converted to 'document.pdf'
 *
 * In a future version of the LiveDocx service, a converter component will be
 * made available.
 */
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
$mailMerge->setLocalTemplate('document.doc');
$mailMerge->assign('dummyFieldName', 'dummyFieldValue');
// necessary as of LiveDocx 1.2
$mailMerge->createDocument();
$document = $mailMerge->retrieveDocument('pdf');
file_put_contents('document.pdf', $document);
unset($mailMerge);