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); }
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); }
<?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);
<?php require_once dirname(__FILE__) . '/../../common.php'; $phpLiveDocx = new Zend_Service_LiveDocx_MailMerge(); $phpLiveDocx->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME)->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD); /* * ALTERNATIVE: Specify username and password in constructor */ /* $phpLiveDocx = new Zend_Service_LiveDocx_MailMerge( array ( 'username' => DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME, 'password' => DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD ) ); */ $phpLiveDocx->setLocalTemplate('template.doc'); $phpLiveDocx->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'); $phpLiveDocx->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')); $phpLiveDocx->assign('connection', $billConnections); $phpLiveDocx->createDocument(); $document = $phpLiveDocx->retrieveDocument('pdf'); unset($phpLiveDocx); file_put_contents('document.pdf', $document);
<?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);
<?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); ?>
<?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); }
<?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); $phpLiveDocx = new Zend_Service_LiveDocx_MailMerge(); $phpLiveDocx->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME)->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD); // ----------------------------------------------------------------------------- $templateName = 'template-1-text-field.docx'; $phpLiveDocx->setLocalTemplate($templateName); printf('Field names in %s:%s', $templateName, PHP_EOL); $fieldNames = $phpLiveDocx->getFieldNames(); foreach ($fieldNames as $fieldName) { printf('- %s%s', $fieldName, PHP_EOL); } // ----------------------------------------------------------------------------- $templateName = 'template-2-text-fields.doc'; $phpLiveDocx->setLocalTemplate($templateName); printf('%sField names in %s:%s', PHP_EOL, $templateName, PHP_EOL); $fieldNames = $phpLiveDocx->getFieldNames(); foreach ($fieldNames as $fieldName) { printf('- %s%s', $fieldName, PHP_EOL); } // ----------------------------------------------------------------------------- $templateName = 'template-block-fields.doc'; $phpLiveDocx->setLocalTemplate($templateName); printf('%sField names in %s:%s', PHP_EOL, $templateName, PHP_EOL); $fieldNames = $phpLiveDocx->getFieldNames(); foreach ($fieldNames as $fieldName) { printf('- %s%s', $fieldName, PHP_EOL); }
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); }
<?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. */ $phpLiveDocx = new Zend_Service_LiveDocx_MailMerge(); $phpLiveDocx->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME)->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD); $phpLiveDocx->setLocalTemplate('document.doc'); $phpLiveDocx->assign('dummyFieldName', 'dummyFieldValue'); // necessary as of LiveDocx 1.2 $phpLiveDocx->createDocument(); $document = $phpLiveDocx->retrieveDocument('pdf'); file_put_contents('document.pdf', $document); unset($phpLiveDocx);