Ejemplo n.º 1
0
 function testLiveDocxAction()
 {
     try {
         $this->_helper->layout()->disableLayout();
         $phpLiveDocx = new Zend_Service_LiveDocx_MailMerge();
         $phpLiveDocx->setUsername('patiwat')->setPassword('4936799');
         //die(realpath( TEMPLATES_DIR.'\invoice_template.doc') );
         $phpLiveDocx->setLocalTemplate(realpath(TEMPLATES_DIR . '\\invoice_template.docx'));
         $phpLiveDocx->assign('phone', '11111111111');
         $phpLiveDocx->createDocument();
         $document = $phpLiveDocx->retrieveDocument('pdf');
         echo realpath(TEM_DOCUMENTS . '\\document.pdf');
         file_put_contents(TEM_DOCUMENTS . '\\document.pdf', $document);
     } catch (Exception $e) {
         echo $e->getMessage();
     }
     $this->render('blank', null, true);
 }
Ejemplo n.º 2
0
 function livedocAction()
 {
     $phpLiveDocx = new Zend_Service_LiveDocx_MailMerge();
     $phpLiveDocx->setUsername('myUsername')->setPassword('myPassword');
     $phpLiveDocx->setLocalTemplate(ROOT_DIR . '/data/article-template.docx');
     $phpLiveDocx->assign('title', 'Magic Graphical Compression Suite v1.9');
     $phpLiveDocx->createDocument();
     $document = $phpLiveDocx->retrieveDocument('pdf');
     file_put_contents('document.pdf', $document);
 }
Ejemplo n.º 3
0
    public function testPdf()
    {
        $user = Zend_Registry::get('config')->livedocx->user;
        $password = Zend_Registry::get('config')->livedocx->password;
        $file_doc = APPLICATION_PATH . "/../var/test/pack.doc";
        $file_pdf = APPLICATION_PATH . "/../var/test/pack.pdf";
        echo $file_doc;
        $mailMerge = new Zend_Service_LiveDocx_MailMerge();
        $mailMerge->setUsername('erwand')->setPassword('online1ld');
        $mailMerge->setLocalTemplate($file_doc);
        $mailMerge->assign('pack_nom', "Performer >45’")->assign('pack_intro', 'nke propose toute une gamme de capteurs et de configurations spécifiquement adaptés à la course ou à la croisière.
De l’afficheur TL25 pied de mât au kit sécurité, tout est prévu pour vous permettre d’atteindre le meilleur niveau de
performance en toute sécurité.')->assign('pack_designation', 'Pack 98-60-259');
        $lstProduct = array(array('pack_product_nb' => '3', 'pack_product_designation' => 'Multifonctions SL50'), array('pack_product_nb' => '1', 'pack_product_designation' => 'Télécommande radio'), array('pack_product_nb' => '1', 'pack_product_designation' => 'capteur Carbowind (hauteur 1,10m)'), array('pack_product_nb' => '1', 'pack_product_designation' => 'Câble Avionic (25m)'), array('pack_product_nb' => '1', 'pack_product_designation' => '1 ultrasonic speedo'), array('pack_product_nb' => '3', 'pack_product_designation' => 'capteur compas Regatta'));
        $mailMerge->assign('pack_product', $lstProduct);
        $mailMerge->createDocument();
        $document = $mailMerge->retrieveDocument('pdf');
        file_put_contents($file_pdf, $document);
    }
Ejemplo n.º 4
0
<?php

require_once dirname(__FILE__) . '/../../common.php';
system('clear');
print Demos_Zend_Service_LiveDocx_Helper::wrapLine(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' => dirname(__FILE__) . '/cache');
$cache = Zend_Cache::factory('Core', 'File', $cacheFrontendOptions, $cacheBackendOptions);
if (!($formats = $cache->load($cacheId))) {
    // Cache miss. Connect to backend service (expensive).
    $phpLiveDocx = new Zend_Service_LiveDocx_MailMerge();
    $phpLiveDocx->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME)->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD);
    $formats = new StdClass();
    $formats->template = $phpLiveDocx->getTemplateFormats();
    $formats->document = $phpLiveDocx->getDocumentFormats();
    $formats->image = $phpLiveDocx->getImageFormats();
    $cache->save($formats, $cacheId);
    unset($phpLiveDocx);
} else {
    // Cache hit. Continue.
}
unset($cache);
printf("Supported TEMPLATE file formats (input)  : %s%s", Demos_Zend_Service_LiveDocx_Helper::arrayDecorator($formats->template), PHP_EOL);
printf("Supported DOCUMENT file formats (output) : %s%s", Demos_Zend_Service_LiveDocx_Helper::arrayDecorator($formats->document), PHP_EOL);
printf("Supported IMAGE file formats (output)    : %s%s", Demos_Zend_Service_LiveDocx_Helper::arrayDecorator($formats->image), PHP_EOL);
print PHP_EOL;
printLine($counter, sprintf('Checking backend WSDL (%01.2fs)', $duration), $result);
$counter++;
// -----------------------------------------------------------------------------
if (defined('DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME') && defined('DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD')) {
    $result = TEST_PASS;
} else {
    $result = TEST_FAIL;
    $failed = true;
}
printLine($counter, 'Checking backend credentials are defined', $result);
$counter++;
// -----------------------------------------------------------------------------
$errorMessage = null;
try {
    $microtime = microtime(true);
    $mailMerge = new Zend_Service_LiveDocx_MailMerge(array('username' => DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME, 'password' => DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD));
    $mailMerge->logIn();
    $duration = microtime(true) - $microtime;
} catch (Zend_Service_LiveDocx_Exception $e) {
    $duration = -1;
    $errorMessage = $e->getMessage();
}
if (is_null($errorMessage)) {
    $result = TEST_PASS;
} else {
    $result = TEST_FAIL;
    $failed = true;
}
printLine($counter, sprintf('Logging into backend service (%01.2fs)', $duration), $result);
$counter++;
// -----------------------------------------------------------------------------
Ejemplo n.º 6
0
<?php

require_once dirname(__FILE__) . '/../../common.php';
$phpLiveDocx = new Zend_Service_LiveDocx_MailMerge();
// Set WSDL of your premium service server
$phpLiveDocx->setWsdl('https://api.example.com/1.2/mailmerge.asmx?WSDL');
$phpLiveDocx->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME)->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD);
$phpLiveDocx->setLocalTemplate('template.docx');
$phpLiveDocx->assign('software', 'Magic Graphical Compression Suite v1.9')->assign('licensee', 'Henry Döner-Meyer')->assign('company', 'Co-Operation')->assign('date', Zend_Date::now()->toString(Zend_Date::DATE_LONG))->assign('time', Zend_Date::now()->toString(Zend_Date::TIME_LONG))->assign('city', 'Berlin')->assign('country', 'Germany');
// Available on premium service only
$phpLiveDocx->setDocumentPassword('aaaaaaaaaa');
// Available on premium service only
$phpLiveDocx->setDocumentAccessPermissions(array('AllowHighLevelPrinting', 'AllowExtractContents'), 'myDocumentAccessPassword');
$phpLiveDocx->createDocument();
$document = $phpLiveDocx->retrieveDocument('pdf');
file_put_contents('document.pdf', $document);
unset($phpLiveDocx);
Ejemplo n.º 7
0
<?php

// require_once dirname(__FILE__) . '/../../common.php';
system('clear');
print Demos_Zend_Service_LiveDocx_Helper::wrapLine(PHP_EOL . 'Checking For Remotely Stored Templates' . PHP_EOL . PHP_EOL);
$mailMerge = new Zend_Service_LiveDocx_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);
<?php

require_once dirname(__FILE__) . '/../../common.php';
$mailMerge = new Zend_Service_LiveDocx_MailMerge();
$mailMerge->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME)->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD);
system('clear');
print Demos_Zend_Service_LiveDocx_Helper::wrapLine(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 . Demos_Zend_Service_LiveDocx_Helper::arrayDecorator($mailMerge->getFontNames()) . PHP_EOL . PHP_EOL);
unset($mailMerge);
Ejemplo n.º 9
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 = Zend_Service_LiveDocx_MailMerge::multiAssocArrayToArrayOfArrayOfString($testValues);
     $this->assertEquals($expectedResults, $actualResults);
 }
Ejemplo n.º 10
0
<?php

require_once dirname(__FILE__) . '/../../common.php';
system('clear');
print Demos_Zend_Service_LiveDocx_Helper::wrapLine(PHP_EOL . 'Checking For Remotely Stored Images' . PHP_EOL . PHP_EOL);
$mailMerge = new Zend_Service_LiveDocx_MailMerge();
$mailMerge->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME)->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD);
print 'Checking whether an image is available... ';
if (true === $mailMerge->imageExists('image-1.png')) {
    print 'EXISTS. ';
} else {
    print 'DOES NOT EXIST. ';
}
print 'DONE' . PHP_EOL;
print PHP_EOL;
unset($mailMerge);
Ejemplo n.º 11
0
<?php

require_once dirname(__FILE__) . '/../../common.php';
system('clear');
print Demos_Zend_Service_LiveDocx_Helper::wrapLine(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 Zend_Service_LiveDocx_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);
}
Ejemplo n.º 12
0
Helper::printCheckEnvironmentLine($counter, sprintf('Checking backend WSDL (%01.2fs)', $duration), $result);
$counter++;
// -----------------------------------------------------------------------------
if (defined('DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME') && defined('DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD')) {
    $result = TEST_PASS;
} else {
    $result = TEST_FAIL;
    $failed = true;
}
Helper::printCheckEnvironmentLine($counter, 'Checking backend credentials are defined', $result);
$counter++;
// -----------------------------------------------------------------------------
$errorMessage = null;
try {
    $microtime = microtime(true);
    $mailMerge = new Zend_Service_LiveDocx_MailMerge(array('username' => DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME, 'password' => DEMOS_ZEND_SERVICE_LIVEDOCX_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;
}
Helper::printCheckEnvironmentLine($counter, sprintf('Logging into backend service (%01.2fs)', $duration), $result);
$counter++;
<?php

require_once dirname(__FILE__) . '/../../common.php';
$mailMerge = new Zend_Service_LiveDocx_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');
$mailMerge->assign('name', 'Daï Lemaitre')->assign('company', 'Megasoft Co-operation')->assign('date', Zend_Date::now()->toString(Zend_Date::DATE_LONG))->assign('image:photo', $photoFilename);
$mailMerge->createDocument();
$document = $mailMerge->retrieveDocument('pdf');
file_put_contents('document.pdf', $document);
$mailMerge->deleteImage($photoFilename);
unset($mailMerge);
Ejemplo n.º 14
0
<?php

require_once dirname(__FILE__) . '/../../common.php';
system('clear');
print Demos_Zend_Service_LiveDocx_Helper::wrapLine(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' => dirname(__FILE__) . '/cache');
$cache = Zend_Cache::factory('Core', 'File', $cacheFrontendOptions, $cacheBackendOptions);
if (!($formats = $cache->load($cacheId))) {
    // Cache miss. Connect to backend service (expensive).
    $mailMerge = new Zend_Service_LiveDocx_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->imageImport = $mailMerge->getImageImportFormats();
    $formats->imageExport = $mailMerge->getImageExportFormats();
    $cache->save($formats, $cacheId);
    unset($mailMerge);
} else {
    // Cache hit. Continue.
}
unset($cache);
printf("Supported TEMPLATE file formats (input)  : %s%s", Demos_Zend_Service_LiveDocx_Helper::arrayDecorator($formats->template), PHP_EOL);
printf("Supported DOCUMENT file formats (output) : %s%s", Demos_Zend_Service_LiveDocx_Helper::arrayDecorator($formats->document), PHP_EOL . PHP_EOL);
printf("Supported IMAGE file formats (import)    : %s%s", Demos_Zend_Service_LiveDocx_Helper::arrayDecorator($formats->imageImport), PHP_EOL);
printf("Supported IMAGE file formats (export)    : %s%s", Demos_Zend_Service_LiveDocx_Helper::arrayDecorator($formats->imageExport), PHP_EOL);
print PHP_EOL;
Ejemplo n.º 15
0
<?php

require_once dirname(__FILE__) . '/../../common.php';
system('clear');
print Demos_Zend_Service_LiveDocx_Helper::wrapLine(PHP_EOL . 'Uploading Locally Stored Images to Server' . PHP_EOL . PHP_EOL);
$mailMerge = new Zend_Service_LiveDocx_MailMerge();
$mailMerge->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME)->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD);
print 'Uploading image... ';
$mailMerge->uploadImage('image-1.png');
print 'DONE.' . PHP_EOL;
print 'Uploading image... ';
$mailMerge->uploadImage('image-2.png');
print 'DONE.' . PHP_EOL;
print PHP_EOL;
unset($mailMerge);
Ejemplo n.º 16
0
<?php

require_once dirname(__FILE__) . '/../../common.php';
system('clear');
print Demos_Zend_Service_LiveDocx_Helper::wrapLine(PHP_EOL . 'Template, Document and Image Formats' . PHP_EOL . PHP_EOL . 'The following formats are supported by LiveDocx:' . PHP_EOL . PHP_EOL);
$mailMerge = new Zend_Service_LiveDocx_MailMerge();
$mailMerge->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME)->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD);
printf("Supported TEMPLATE file formats (input)  : %s%s", Demos_Zend_Service_LiveDocx_Helper::arrayDecorator($mailMerge->getTemplateFormats()), PHP_EOL);
printf("Supported DOCUMENT file formats (output) : %s%s", Demos_Zend_Service_LiveDocx_Helper::arrayDecorator($mailMerge->getDocumentFormats()), PHP_EOL);
printf("Supported IMAGE file formats (output)    : %s%s", Demos_Zend_Service_LiveDocx_Helper::arrayDecorator($mailMerge->getImageFormats()), PHP_EOL);
print PHP_EOL;
unset($mailMerge);
Ejemplo n.º 17
0
<?php

require_once dirname(__FILE__) . '/../../common.php';
system('clear');
print Demos_Zend_Service_LiveDocx_Helper::wrapLine(PHP_EOL . 'Using Hosted Solution and Fully-Licensed Servers' . PHP_EOL . PHP_EOL . 'This sample application illustrates how to use Zend_Service_LiveDocx_MailMerge with hosted and fully-licensed LiveDocx servers, by specifying an alternative SOAP client (must be instance of Zend_Soap_Client).' . PHP_EOL . PHP_EOL);
$phpLiveDocx = new Zend_Service_LiveDocx_MailMerge();
$phpLiveDocx->setWsdl('https://api.example.com/1.2/mailmerge.asmx?WSDL')->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME)->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD);
$phpLiveDocx->getTemplateFormats();
// then call methods as usual
printf('Username : %s%sPassword : %s%s    WSDL : %s%s%s', $phpLiveDocx->getUsername(), PHP_EOL, $phpLiveDocx->getPassword(), PHP_EOL, $phpLiveDocx->getWsdl(), PHP_EOL, PHP_EOL);
unset($phpLiveDocx, $mySoapClient);
Ejemplo n.º 18
0
<?php

require_once dirname(__FILE__) . '/../../common.php';
system('clear');
$cacheId = md5(__FILE__);
$cacheFrontendOptions = array('lifetime' => 2592000, 'automatic_serialization' => true);
$cacheBackendOptions = array('cache_dir' => dirname(__FILE__) . '/cache');
$cache = Zend_Cache::factory('Core', 'File', $cacheFrontendOptions, $cacheBackendOptions);
if (!($fonts = $cache->load($cacheId))) {
    // Cache miss. Connect to backend service (expensive).
    $phpLiveDocx = new Zend_Service_LiveDocx_MailMerge();
    $phpLiveDocx->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME)->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD);
    $fonts = $phpLiveDocx->getFontNames();
    $cache->save($fonts, $cacheId);
    unset($phpLiveDocx);
} else {
    // Cache hit. Continue.
}
unset($cache);
print Demos_Zend_Service_LiveDocx_Helper::wrapLine(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 . Demos_Zend_Service_LiveDocx_Helper::arrayDecorator($fonts) . PHP_EOL . PHP_EOL);
print PHP_EOL;
unset($phpLiveDocx);
Ejemplo n.º 19
0
Archivo: list.php Proyecto: netvlies/zf
<?php

// require_once dirname(__FILE__) . '/../../common.php';
system('clear');
print Demos_Zend_Service_LiveDocx_Helper::wrapLine(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 Zend_Service_LiveDocx_MailMerge();
$mailMerge->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME)->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD);
print Demos_Zend_Service_LiveDocx_Helper::listDecorator($mailMerge->listTemplates());
unset($mailMerge);
Ejemplo n.º 20
0
<?php

require_once dirname(__FILE__) . '/../../common.php';
system('clear');
$cacheId = md5(__FILE__);
$cacheFrontendOptions = array('lifetime' => 2592000, 'automatic_serialization' => true);
$cacheBackendOptions = array('cache_dir' => dirname(__FILE__) . '/cache');
$cache = Zend_Cache::factory('Core', 'File', $cacheFrontendOptions, $cacheBackendOptions);
if (!($fonts = $cache->load($cacheId))) {
    // Cache miss. Connect to backend service (expensive).
    $mailMerge = new Zend_Service_LiveDocx_MailMerge();
    $mailMerge->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME)->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD);
    $fonts = $mailMerge->getFontNames();
    $cache->save($fonts, $cacheId);
    unset($mailMerge);
} else {
    // Cache hit. Continue.
}
unset($cache);
print Demos_Zend_Service_LiveDocx_Helper::wrapLine(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 . Demos_Zend_Service_LiveDocx_Helper::arrayDecorator($fonts) . PHP_EOL . PHP_EOL);
print PHP_EOL;
unset($mailMerge);
<?php

require_once dirname(__FILE__) . '/../../common.php';
$mailMerge = new Zend_Service_LiveDocx_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', Zend_Date::now()->toString(Zend_Date::DATE_LONG))->setFieldValue('time', Zend_Date::now()->toString(Zend_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);
<?php

require_once dirname(__FILE__) . '/../../common.php';
$mailMerge = new Zend_Service_LiveDocx_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', Zend_Date::now()->toString(Zend_Date::DATE_LONG))->assign('time', Zend_Date::now()->toString(Zend_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);
Ejemplo n.º 23
0
<?php

// require_once dirname(__FILE__) . '/../../common.php';
/**
 * Converting documents between supported formats
 * 
 * The primary goal of Zend_Service_LiveDocx_MailMerge 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.
 */
$mailMerge = new Zend_Service_LiveDocx_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);
Ejemplo n.º 24
0
<?php

require_once dirname(__FILE__) . '/../../common.php';
system('clear');
print Demos_Zend_Service_LiveDocx_Helper::wrapLine(PHP_EOL . 'Using the Free Public Server' . PHP_EOL . PHP_EOL . 'This sample application illustrates how to use Zend_Service_LiveDocx_MailMerge with the free, public LiveDocx server.' . PHP_EOL . PHP_EOL);
$mailMerge = new Zend_Service_LiveDocx_MailMerge();
$mailMerge->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME)->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_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);
// -----------------------------------------------------------------------------
// Alternatively, you can pass username and password in the constructor.
$mailMerge = new Zend_Service_LiveDocx_MailMerge(array('username' => DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME, 'password' => DEMOS_ZEND_SERVICE_LIVEDOCX_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);
Ejemplo n.º 25
0
<?php

require_once dirname(__FILE__) . '/../../common.php';
system('clear');
print Demos_Zend_Service_LiveDocx_Helper::wrapLine(PHP_EOL . 'Using the Free Public Server' . PHP_EOL . PHP_EOL . 'This sample application illustrates how to use Zend_Service_LiveDocx_MailMerge with the free, public LiveDocx server.' . PHP_EOL . PHP_EOL);
$phpLiveDocx = new Zend_Service_LiveDocx_MailMerge();
$phpLiveDocx->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME)->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD);
$phpLiveDocx->getTemplateFormats();
// then call methods as usual
printf('Username : %s%sPassword : %s%s    WSDL : %s%s%s', $phpLiveDocx->getUsername(), PHP_EOL, $phpLiveDocx->getPassword(), PHP_EOL, $phpLiveDocx->getWsdl(), PHP_EOL, PHP_EOL);
unset($phpLiveDocx);
// -----------------------------------------------------------------------------
// Alternatively, you can pass username and password in the constructor.
$phpLiveDocx = new Zend_Service_LiveDocx_MailMerge(array('username' => DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME, 'password' => DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD));
$phpLiveDocx->getTemplateFormats();
// then call methods as usual
printf('Username : %s%sPassword : %s%s    WSDL : %s%s%s', $phpLiveDocx->getUsername(), PHP_EOL, $phpLiveDocx->getPassword(), PHP_EOL, $phpLiveDocx->getWsdl(), PHP_EOL, PHP_EOL);
unset($phpLiveDocx);
Ejemplo n.º 26
0
<?php

$phpLiveDocx = new Zend_Service_LiveDocx_MailMerge(array('username' => 'myUsername', 'password' => 'myPassword'));
$phpLiveDocx->setLocalTemplate($argv[0]);
// necessary as of LiveDocx 1.2
$phpLiveDocx->assign('dummyFieldName', 'dummyFieldValue');
$phpLiveDocx->createDocument();
$current_filename = str_replace("." . end(explode('.', $argv[0])), $argv[1], $argv[0]);
$document = $phpLiveDocx->retrieveDocument($current_filename);
file_put_contents($current_filename, $document);
unset($phpLiveDocx);
?>

Ejemplo n.º 27
0
<?php

// require_once dirname(__FILE__) . '/../../common.php';
$mailMerge = new Zend_Service_LiveDocx_MailMerge();
$mailMerge->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME)->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD);
/*
 * ALTERNATIVE: Specify username and password in constructor
 */
/*
$mailMerge = new Zend_Service_LiveDocx_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' => Zend_Date::now()->toString(Zend_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', Zend_Date::now()->toString(Zend_Date::MONTH_NAME), Zend_Date::now()->toString(Zend_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);
Ejemplo n.º 28
0
// -----------------------------------------------------------------------------
// Logger to output status messages
$logger = new Zend_Log(new Zend_Log_Writer_Stream('php://output'));
Zend_Registry::set('logger', $logger);
// -----------------------------------------------------------------------------
// Create temporary directory
$tempDirectory = sys_get_temp_dir() . '/' . md5(rand(1, 10000) . __FILE__);
if (is_dir($tempDirectory)) {
    recursiveRemoveDirectory($tempDirectory);
}
$logger->log(sprintf('Making temporary directory %s.', $tempDirectory), Zend_Log::INFO);
mkdir($tempDirectory);
// -----------------------------------------------------------------------------
// Generate temporary documents
$tempFilenames = array();
$mailMerge = new Zend_Service_LiveDocx_MailMerge();
$mailMerge->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME)->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD);
$mailMerge->setLocalTemplate('template.docx');
for ($iteration = 1; $iteration <= $iterations; $iteration++) {
    $tempFilename = sprintf('%s/%010s.pdf', $tempDirectory, $iteration);
    $tempFilenames[] = $tempFilename;
    $mailMerge->assign('software', randomString())->assign('licensee', randomString())->assign('company', randomString())->assign('date', Zend_Date::now()->toString(Zend_Date::DATE_LONG))->assign('time', Zend_Date::now()->toString(Zend_Date::TIME_LONG))->assign('city', randomString())->assign('country', randomString());
    $mailMerge->createDocument();
    file_put_contents($tempFilename, $mailMerge->retrieveDocument('pdf'));
    $logger->log(sprintf('Generating temporary document %s.', $tempFilename), Zend_Log::INFO);
}
unset($mailMerge);
// -----------------------------------------------------------------------------
// Concatenate temporary documents and write output document
$outputFilename = './document-concat.pdf';
$logger->log('Concatenating temporary documents...', Zend_Log::INFO);
Ejemplo n.º 29
0
<?php

// require_once dirname(__FILE__) . '/../../common.php';
system('clear');
print Demos_Zend_Service_LiveDocx_Helper::wrapLine(PHP_EOL . 'Deleting All Remotely Stored Templates' . PHP_EOL . PHP_EOL);
$mailMerge = new Zend_Service_LiveDocx_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']);
    $mailMerge->deleteTemplate($result['filename']);
    print ' - DELETED.' . PHP_EOL;
    $counter++;
}
print PHP_EOL;
unset($mailMerge);
Ejemplo n.º 30
0
<?php

// require_once dirname(__FILE__) . '/../../common.php';
system('clear');
print Demos_Zend_Service_LiveDocx_Helper::wrapLine(PHP_EOL . 'Uploading Locally Stored Templates to Server' . PHP_EOL . PHP_EOL);
$mailMerge = new Zend_Service_LiveDocx_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);