コード例 #1
0
ファイル: delete-all.php プロジェクト: bradley-holt/zf2
<?php

require_once dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'Bootstrap.php';
use Zend\Service\LiveDocx\Helper;
use Zend\Service\LiveDocx\MailMerge;
Helper::printLine(PHP_EOL . 'Deleting All Remotely Stored Images' . PHP_EOL . PHP_EOL);
$mailMerge = new MailMerge();
$mailMerge->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME)->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD);
$counter = 1;
foreach ($mailMerge->listImages() as $result) {
    printf('%d) %s', $counter, $result['filename']);
    $mailMerge->deleteImage($result['filename']);
    print ' - DELETED.' . PHP_EOL;
    $counter++;
}
print PHP_EOL;
unset($mailMerge);
コード例 #2
0
$iterations = 3;
// -----------------------------------------------------------------------------
// Logger to output status messages
$logger = new Logger(new Writer('php://stdout'));
// -----------------------------------------------------------------------------
// Create temporary directory
$tempDirectory = sys_get_temp_dir() . DIRECTORY_SEPARATOR . md5(rand(1, 10000) . __FILE__);
if (is_dir($tempDirectory)) {
    recursiveRemoveDirectory($tempDirectory);
}
$logger->log(sprintf('Making temporary directory %s.', $tempDirectory), Logger::INFO);
mkdir($tempDirectory);
// -----------------------------------------------------------------------------
// Generate temporary documents
$tempFilenames = array();
$mailMerge = new MailMerge();
$mailMerge->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME)->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD);
$mailMerge->setLocalTemplate('template.docx');
$date = new DateTime();
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', $date->format('Y-m-d'))->assign('time', $date->format('H:i:s'))->assign('city', randomString())->assign('country', randomString());
    $mailMerge->createDocument();
    file_put_contents($tempFilename, $mailMerge->retrieveDocument('pdf'));
    $logger->log(sprintf('Generating temporary document %s.', $tempFilename), Logger::INFO);
}
unset($mailMerge);
// -----------------------------------------------------------------------------
// Concatenate temporary documents and write output document
$outputFilename = __DIR__ . DIRECTORY_SEPARATOR . 'document-concat.pdf';
コード例 #3
0
ファイル: upload.php プロジェクト: bradley-holt/zf2
<?php

require_once dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'Bootstrap.php';
use Zend\Service\LiveDocx\Helper;
use Zend\Service\LiveDocx\MailMerge;
Helper::printLine(PHP_EOL . 'Uploading Locally Stored Images to Server' . PHP_EOL . PHP_EOL);
$mailMerge = new MailMerge();
$mailMerge->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME)->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD);
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);
コード例 #4
0
ファイル: generate-document.php プロジェクト: raZ3l/zf2
<?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->assign('software', 'Magic Graphical Compression Suite v1.9')->assign('licensee', 'Henry Döner-Meyer')->assign('company', 'Co-Operation')->assign('date', $date->format('Y-m-d'))->assign('time', $date->format('H:i:s'))->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'     => Date::now()->toString(Date::DATE_LONG),
        'time'     => Date::now()->toString(Date::TIME_LONG),
コード例 #5
0
ファイル: check-environment.php プロジェクト: alab1001101/zf2
        $duration = microtime(true) - $microtime;
        $result = TEST_PASS;
    } else {
        $duration = -1;
        $result = TEST_FAIL;
        $failed = true;
    }
    Helper::printLineToc($counter, sprintf('[PREMIUM] Checking backend WSDL (%01.2fs)', $duration), $result);
    $counter++;
}
// -----------------------------------------------------------------------------
if (defined('DEMOS_ZEND_SERVICE_LIVEDOCX_PREMIUM_USERNAME') && defined('DEMOS_ZEND_SERVICE_LIVEDOCX_PREMIUM_PASSWORD') && defined('DEMOS_ZEND_SERVICE_LIVEDOCX_PREMIUM_WSDL') && false !== DEMOS_ZEND_SERVICE_LIVEDOCX_PREMIUM_USERNAME && false !== DEMOS_ZEND_SERVICE_LIVEDOCX_PREMIUM_PASSWORD && false !== DEMOS_ZEND_SERVICE_LIVEDOCX_PREMIUM_WSDL) {
    $errorMessage = null;
    try {
        $microtime = microtime(true);
        $mailMerge = new MailMerge();
        $mailMerge->setWsdl(DEMOS_ZEND_SERVICE_LIVEDOCX_PREMIUM_WSDL)->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_PREMIUM_USERNAME)->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PREMIUM_PASSWORD)->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('[PREMIUM] Logging into backend service (%01.2fs)', $duration), $result);
    $counter++;
コード例 #6
0
ファイル: template-exists.php プロジェクト: alab1001101/zf2
<?php

require_once dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'Bootstrap.php';
use Zend\Service\LiveDocx\Helper;
use Zend\Service\LiveDocx\MailMerge;
Helper::printLine(PHP_EOL . 'Checking For Remotely Stored Templates' . PHP_EOL . PHP_EOL);
$mailMerge = new MailMerge();
$mailMerge->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME)->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD);
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);
コード例 #7
0
ファイル: generate-bitmaps.php プロジェクト: alab1001101/zf2
<?php

require_once dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'Bootstrap.php';
use Zend\Date\Date;
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');
$mailMerge->assign('software', 'Magic Graphical Compression Suite v1.9')->assign('licensee', 'Daï Lemaitre')->assign('company', 'Megasoft Co-operation')->assign('date', Date::now()->toString(Date::DATE_LONG))->assign('time', Date::now()->toString(Date::TIME_LONG))->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);
コード例 #8
0
<?php

require_once __DIR__ . '/common.php';
use Zend\Service\LiveDocx\MailMerge;
// -----------------------------------------------------------------------------
$mailMerge = new MailMerge();
$mailMerge->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME)->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD);
// -----------------------------------------------------------------------------
foreach ($templateFilesnames as $_templateFilesname) {
    if ($mailMerge->templateExists($_templateFilesname)) {
        $mailMerge->deleteTemplate($_templateFilesname);
    }
    $mailMerge->uploadTemplate($_templateFilesname);
}
// -----------------------------------------------------------------------------
$mailMerge->setIgnoreSubTemplates(true);
// <-- Does NOT include any sub-templates.
$mailMerge->setRemoteTemplate($templateFilename);
$mailMerge->createDocument();
$document = $mailMerge->retrieveDocument('pdf');
file_put_contents('document1.pdf', $document);
// -----------------------------------------------------------------------------
$mailMerge->setIgnoreSubTemplates(false);
// <-- Includes all sub-templates.
//     Default, when setIgnoreSubTemplates is not called.
$mailMerge->setRemoteTemplate($templateFilename);
$mailMerge->createDocument();
$document = $mailMerge->retrieveDocument('pdf');
file_put_contents('document2.pdf', $document);
// -----------------------------------------------------------------------------
unset($mailMerge);
コード例 #9
0
ファイル: download.php プロジェクト: alab1001101/zf2
<?php

require_once dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'Bootstrap.php';
use Zend\Service\LiveDocx\Helper;
use Zend\Service\LiveDocx\MailMerge;
Helper::printLine(PHP_EOL . 'Downloading Remotely Stored Templates' . PHP_EOL . PHP_EOL);
$mailMerge = new MailMerge();
$mailMerge->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME)->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD);
$counter = 1;
foreach ($mailMerge->listTemplates() as $result) {
    printf('%d) %s', $counter, $result['filename']);
    $template = $mailMerge->downloadTemplate($result['filename']);
    file_put_contents('downloaded-' . $result['filename'], $template);
    print ' - DOWNLOADED.' . PHP_EOL;
    $counter++;
}
print PHP_EOL;
unset($mailMerge);
コード例 #10
0
ファイル: generate-document.php プロジェクト: raZ3l/zf2
<?php

require_once dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'Bootstrap.php';
use DateTime;
use Zend\Service\LiveDocx\MailMerge;
$mailMerge = new MailMerge();
// Set WSDL of your *premium* service server
$mailMerge->setWsdl(DEMOS_ZEND_SERVICE_LIVEDOCX_PREMIUM_WSDL);
// Set username and password of your *premium* service server
$mailMerge->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_PREMIUM_USERNAME)->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PREMIUM_PASSWORD);
$mailMerge->setLocalTemplate('template.docx');
$date = new DateTime();
$mailMerge->assign('software', 'Magic Graphical Compression Suite v1.9')->assign('licensee', 'Henry Döner-Meyer')->assign('company', 'Co-Operation')->assign('date', $date->format('Y-m-d'))->assign('time', $date->format('H:i:s'))->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);
コード例 #11
0
ファイル: LiveDocxTest.php プロジェクト: stunti/zf2
 public function testSetWSDLGetWSDLWithSoapClient()
 {
     $wsdl = 'http://example.com/somewhere.wsdl';
     $mailMerge = new MailMerge();
     $soapClient = new \Zend\Soap\Client\Client();
     $soapClient->setWSDL($wsdl);
     $mailMerge->setSoapClient($soapClient);
     $this->assertTrue($wsdl === $mailMerge->getWSDL());
     unset($mailMerge);
 }
コード例 #12
0
ファイル: generate-document.php プロジェクト: raZ3l/zf2
<?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);
/**
 * Image Source:
 * iStock_000003413016Medium_business-man-with-hands-up.jpg
 */
$photoFilename = 'dailemaitre.jpg';
if (!$mailMerge->imageExists($photoFilename)) {
    $mailMerge->uploadImage($photoFilename);
}
$mailMerge->setLocalTemplate('template.docx');
$date = new DateTime();
$mailMerge->assign('name', 'Daï Lemaitre')->assign('company', 'Megasoft Co-operation')->assign('date', $date->format('Y-m-d'))->assign('image:photo', $photoFilename);
$mailMerge->createDocument();
$document = $mailMerge->retrieveDocument('pdf');
file_put_contents('document.pdf', $document);
$mailMerge->deleteImage($photoFilename);
unset($mailMerge);
コード例 #13
0
ファイル: upload.php プロジェクト: alab1001101/zf2
<?php

require_once dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'Bootstrap.php';
use Zend\Service\LiveDocx\Helper;
use Zend\Service\LiveDocx\MailMerge;
Helper::printLine(PHP_EOL . 'Uploading Locally Stored Templates to Server' . PHP_EOL . PHP_EOL);
$mailMerge = new MailMerge();
$mailMerge->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME)->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD);
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);
コード例 #14
0
ファイル: check-environment.php プロジェクト: necrogami/zf2
}

// -----------------------------------------------------------------------------

if (defined('DEMOS_ZEND_SERVICE_LIVEDOCX_PREMIUM_USERNAME')     &&
        defined('DEMOS_ZEND_SERVICE_LIVEDOCX_PREMIUM_PASSWORD') &&
        defined('DEMOS_ZEND_SERVICE_LIVEDOCX_PREMIUM_WSDL')     &&
        false !== DEMOS_ZEND_SERVICE_LIVEDOCX_PREMIUM_USERNAME  &&
        false !== DEMOS_ZEND_SERVICE_LIVEDOCX_PREMIUM_PASSWORD  &&
        false !== DEMOS_ZEND_SERVICE_LIVEDOCX_PREMIUM_WSDL) {

    $errorMessage = null;

    try {
        $microtime = microtime(true);
        $mailMerge = new MailMerge();
        $mailMerge->setWsdl(DEMOS_ZEND_SERVICE_LIVEDOCX_PREMIUM_WSDL)
                  ->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_PREMIUM_USERNAME)
                  ->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PREMIUM_PASSWORD)
                  ->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;
コード例 #15
0
ファイル: list-template-info.php プロジェクト: stunti/zf2
<?php

require_once dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'Bootstrap.php';
use Zend\Service\LiveDocx\Helper;
use Zend\Service\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_ZEND_SERVICE_LIVEDOCX_USERNAME)->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD);
// -----------------------------------------------------------------------------
$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) {
    printf('- %s%s', $fieldName, PHP_EOL);
コード例 #16
0
ファイル: check-environment.php プロジェクト: stunti/zf2
        $duration = microtime(true) - $microtime;
        $result = TEST_PASS;
    } else {
        $duration = -1;
        $result = TEST_FAIL;
        $failed = true;
    }
    Helper::printCheckEnvironmentLine($counter, sprintf('[PREMIUM] Checking backend WSDL (%01.2fs)', $duration), $result);
    $counter++;
}
// -----------------------------------------------------------------------------
if (defined('DEMOS_ZEND_SERVICE_LIVEDOCX_PREMIUM_USERNAME') && defined('DEMOS_ZEND_SERVICE_LIVEDOCX_PREMIUM_PASSWORD') && defined('DEMOS_ZEND_SERVICE_LIVEDOCX_PREMIUM_WSDL') && false !== DEMOS_ZEND_SERVICE_LIVEDOCX_PREMIUM_USERNAME && false !== DEMOS_ZEND_SERVICE_LIVEDOCX_PREMIUM_PASSWORD && false !== DEMOS_ZEND_SERVICE_LIVEDOCX_PREMIUM_WSDL) {
    $errorMessage = null;
    try {
        $microtime = microtime(true);
        $mailMerge = new MailMerge();
        $mailMerge->setWSDL(DEMOS_ZEND_SERVICE_LIVEDOCX_PREMIUM_WSDL);
        $mailMerge->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_PREMIUM_USERNAME);
        $mailMerge->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PREMIUM_PASSWORD);
        $mailMerge->logIn();
        $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;
コード例 #17
0
ファイル: generate-metafiles.php プロジェクト: stunti/zf2
<?php

require_once dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'Bootstrap.php';
use Zend\Date\Date;
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');
$mailMerge->setFieldValue('software', 'Magic Graphical Compression Suite v1.9')->setFieldValue('licensee', 'Henry Döner-Meyer')->setFieldValue('company', 'Megasoft Co-operation')->setFieldValue('date', Date::now()->toString(Date::DATE_LONG))->setFieldValue('time', Date::now()->toString(Date::TIME_LONG))->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);
コード例 #18
0
require_once dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'Bootstrap.php';
use Zend\Cache\Cache;
use Zend\Service\LiveDocx\Helper;
use Zend\Service\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 . '(Note these method calls are cached for maximum performance. The supported formats change very infrequently, hence, they are good candidates to be cached.)' . PHP_EOL . PHP_EOL);
$cacheId = md5(__FILE__);
$cacheFrontendOptions = array('lifetime' => 2592000, 'automatic_serialization' => true);
$cacheBackendOptions = array('cache_dir' => __DIR__ . '/cache');
if (!is_dir($cacheBackendOptions['cache_dir'])) {
    mkdir($cacheBackendOptions['cache_dir']);
}
$cache = Cache::factory('Core', 'File', $cacheFrontendOptions, $cacheBackendOptions);
if (!($formats = $cache->load($cacheId))) {
    // Cache miss. Connect to backend service (expensive).
    $mailMerge = new MailMerge();
    $mailMerge->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME)->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD);
    $formats = new \StdClass();
    $formats->template = $mailMerge->getTemplateFormats();
    $formats->document = $mailMerge->getDocumentFormats();
    $formats->image = $mailMerge->getImageFormats();
    $cache->save($formats, $cacheId);
    unset($mailMerge);
} else {
    // Cache hit. Continue.
}
unset($cache);
printf("Supported TEMPLATE file formats (input)  : %s%s", Helper::arrayDecorator($formats->template), PHP_EOL);
printf("Supported DOCUMENT file formats (output) : %s%s", Helper::arrayDecorator($formats->document), PHP_EOL);
printf("Supported IMAGE file formats (output)    : %s%s", Helper::arrayDecorator($formats->image), PHP_EOL);
print PHP_EOL;
コード例 #19
0
ファイル: MailMergeTest.php プロジェクト: rexmac/zf2
 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);
 }
コード例 #20
0
ファイル: generate-document.php プロジェクト: alab1001101/zf2
<?php

require_once dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'Bootstrap.php';
use Zend\Date\Date;
use Zend\Service\LiveDocx\Helper;
use Zend\Service\LiveDocx\MailMerge;
$mailMerge = new MailMerge();
$mailMerge->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME)->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD);
/*
 * ALTERNATIVE: Specify username and password in constructor
 */
/*
$mailMerge = new MailMerge(
    array (
        'username' => DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME,
        'password' => DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD
    )
);
*/
$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' => Date::now()->toString(Date::DATE_LONG), 'name' => 'James Henry Brown', 'service_phone' => '+22 (0)333 444 559', 'service_fax' => '+22 (0)333 444 558', 'month' => sprintf('%s %s', Date::now()->toString(Date::MONTH_NAME), Date::now()->toString(Date::YEAR)), '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);
コード例 #21
0
ファイル: hosted-licensed.php プロジェクト: alab1001101/zf2
<?php

require_once dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'Bootstrap.php';
use Zend\Service\LiveDocx\Helper;
use Zend\Service\LiveDocx\MailMerge;
Helper::printLine(PHP_EOL . 'Using Hosted Solution and Fully-Licensed Servers' . PHP_EOL . PHP_EOL . 'This sample application illustrates how to use the Zend Framework LiveDocx component with hosted and fully-licensed LiveDocx servers, by specifying the server\'s WSDL.' . PHP_EOL . PHP_EOL);
$mailMerge = new MailMerge();
$mailMerge->setWsdl(DEMOS_ZEND_SERVICE_LIVEDOCX_PREMIUM_WSDL)->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_PREMIUM_USERNAME)->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PREMIUM_PASSWORD);
$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);
コード例 #22
0
<?php

require_once __DIR__ . '/common.php';
use Zend\Service\LiveDocx\MailMerge;
// -----------------------------------------------------------------------------
$mailMerge = new MailMerge();
$mailMerge->setWsdl(DEMOS_ZEND_SERVICE_LIVEDOCX_PREMIUM_WSDL)->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_PREMIUM_USERNAME)->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PREMIUM_PASSWORD);
// -----------------------------------------------------------------------------
foreach ($templateFilesnames as $_templateFilesname) {
    if ($mailMerge->templateExists($_templateFilesname)) {
        $mailMerge->deleteTemplate($_templateFilesname);
    }
    $mailMerge->uploadTemplate($_templateFilesname);
}
// -----------------------------------------------------------------------------
$mailMerge->setSubTemplateIgnoreList(array($subTemplate1Filename, $subTemplate2Filename));
$mailMerge->setRemoteTemplate($templateFilename);
$mailMerge->createDocument();
$document = $mailMerge->retrieveDocument('pdf');
file_put_contents('document1.pdf', $document);
// -----------------------------------------------------------------------------
$mailMerge->setSubTemplateIgnoreList(array($subTemplate1Filename));
$mailMerge->setRemoteTemplate($templateFilename);
$mailMerge->createDocument();
$document = $mailMerge->retrieveDocument('pdf');
file_put_contents('document2.pdf', $document);
// -----------------------------------------------------------------------------
$mailMerge->setSubTemplateIgnoreList(array($subTemplate2Filename));
$mailMerge->setRemoteTemplate($templateFilename);
$mailMerge->createDocument();
$document = $mailMerge->retrieveDocument('pdf');
コード例 #23
0
ファイル: public-zend_config.php プロジェクト: stunti/zf2
<?php

require_once dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'Bootstrap.php';
use Zend\Config\Ini;
use Zend\Service\LiveDocx\Helper;
use Zend\Service\LiveDocx\MailMerge;
Helper::printLine(PHP_EOL . 'Using the Public LiveDocx Service with \\Zend\\Config\\Config' . PHP_EOL . PHP_EOL . 'This sample application illustrates how to use the Zend Framework LiveDocx component with a \\Zend\\Config\\Config object. This is useful, for example, to store connection credentials in an external ini file.' . PHP_EOL . PHP_EOL);
$options = new Ini('credentials.ini');
$mailMerge = new MailMerge($options);
$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, $options);
コード例 #24
0
<?php

require_once dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'Bootstrap.php';
use Zend\Service\LiveDocx\MailMerge;
use Zend\Service\LiveDocx\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();
// Set WSDL of your *premium* service server
$mailMerge->setWsdl(DEMOS_ZEND_SERVICE_LIVEDOCX_PREMIUM_WSDL);
// Set username and password of your *premium* service server
$mailMerge->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_PREMIUM_USERNAME)->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PREMIUM_PASSWORD);
Helper::printLine(implode(', ', $mailMerge->getDocumentAccessOptions()) . '.' . PHP_EOL . PHP_EOL);
unset($mailMerge);
コード例 #25
0
<?php

require_once dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'Bootstrap.php';
use Zend\Service\LiveDocx\Helper;
use Zend\Service\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_ZEND_SERVICE_LIVEDOCX_USERNAME)->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD);
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->getImageFormats()), PHP_EOL);
print PHP_EOL;
unset($mailMerge);
コード例 #26
0
<?php

require_once dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'Bootstrap.php';
use Zend\Cache\StorageFactory;
use Zend\Service\LiveDocx\Helper;
use Zend\Service\LiveDocx\MailMerge;
$cacheId = md5(__FILE__);
$cache = array('adapter' => 'FileSystem', 'options' => array('cache_dir' => __DIR__ . '/cache'));
if (!is_dir($cache['options']['cache_dir'])) {
    mkdir($cache['options']['cache_dir']);
}
$cache = StorageFactory::factory($cache);
if (!($fonts = $cache->getItem($cacheId))) {
    // Cache miss. Connect to backend service (expensive).
    $mailMerge = new MailMerge();
    $mailMerge->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME)->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD);
    $fonts = $mailMerge->getFontNames();
    $cache->addItem($fonts, $cacheId);
    unset($mailMerge);
} else {
    // Cache hit. Continue.
}
unset($cache);
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 . '(Note this method call is cached for maximum performance. The supported formats change very infrequently, hence, they are good candidates to be cached.)' . PHP_EOL . PHP_EOL . Helper::arrayDecorator($fonts) . PHP_EOL . PHP_EOL);
print PHP_EOL;
unset($mailMerge);
コード例 #27
0
ファイル: list.php プロジェクト: alab1001101/zf2
<?php

require_once dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'Bootstrap.php';
use Zend\Service\LiveDocx\Helper;
use Zend\Service\LiveDocx\MailMerge;
Helper::printLine(PHP_EOL . 'Remotely Stored Templates' . PHP_EOL . PHP_EOL . 'The following templates are currently stored on the LiveDocx server:' . PHP_EOL . PHP_EOL);
$mailMerge = new MailMerge();
$mailMerge->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME)->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD);
print Helper::listDecorator($mailMerge->listTemplates());
unset($mailMerge);
コード例 #28
0
ファイル: convert-document.php プロジェクト: raZ3l/zf2
<?php

require_once dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . '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 Zend\Service\LiveDocx\MailMerge;
$mailMerge = new MailMerge();
$mailMerge->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME)->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD);
$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);
コード例 #29
0
ファイル: show-supported-fonts.php プロジェクト: stunti/zf2
<?php

require_once dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'Bootstrap.php';
use Zend\Service\LiveDocx\Helper;
use Zend\Service\LiveDocx\MailMerge;
$mailMerge = new MailMerge();
$mailMerge->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME)->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD);
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);
コード例 #30
0
ファイル: public-zend_config.php プロジェクト: necrogami/zf2
use Zend\Config\Factory as ConfigFactory;
use Zend\Service\LiveDocx\Helper;
use Zend\Service\LiveDocx\MailMerge;

Helper::printLine(
    PHP_EOL . 'Using the Public LiveDocx Service with \Zend\Config\Config' .
    PHP_EOL . 
    PHP_EOL . 'This sample application illustrates how to use the Zend Framework LiveDocx component with a \Zend\Config\Config object. This is useful, for example, to store connection credentials in an external ini file.' .
    PHP_EOL .
    PHP_EOL
);

$options = ConfigFactory::fromFile('credentials.ini', true);

$mailMerge = new MailMerge($options);

$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, $options);