#!/usr/bin/php <?php require_once dirname(__FILE__) . '/../../common.php'; $phpLiveDocx = new Tis_Service_LiveDocx_MailMerge(USERNAME, PASSWORD); print 'Uploading template... '; $phpLiveDocx->uploadTemplate('template-1.docx'); print "DONE.\n"; print 'Uploading template... '; $phpLiveDocx->uploadTemplate('template-2.docx'); print "DONE.\n";
#!/usr/bin/php <?php require_once dirname(__FILE__) . '/../../common.php'; $phpLiveDocx = new Tis_Service_LiveDocx_MailMerge(USERNAME, PASSWORD); printf("Supported TEMPLATE file formats (input) : %s.\n", arrayDecorator($phpLiveDocx->getTemplateFormats())); printf("Supported DOCUMENT file formats (output) : %s.\n", arrayDecorator($phpLiveDocx->getDocumentFormats())); unset($phpLiveDocx);
#!/usr/bin/php <?php require_once dirname(__FILE__) . '/../../common.php'; $phpLiveDocx = new Tis_Service_LiveDocx_MailMerge(USERNAME, PASSWORD); $counter = 1; foreach ($phpLiveDocx->listTemplates() as $result) { printf('%d) %s', $counter, $result['filename']); $phpLiveDocx->deleteTemplate($result['filename']); printf(" - DELETED.\n"); $counter++; } unset($phpLiveDocx);
define('PATH_BASE', dirname(__FILE__)); define('PATH_INPUT', PATH_BASE . DIRECTORY_SEPARATOR . 'queue'); define('PATH_INPUT_DONE', PATH_BASE . DIRECTORY_SEPARATOR . 'queue_done'); define('PATH_OUTPUT', PATH_BASE . DIRECTORY_SEPARATOR . 'output'); define('FILENAME_LOCK', PATH_BASE . DIRECTORY_SEPARATOR . 'job.lock'); // ----------------------------------------------------------------------------- $date = new Zend_Date(LOCALE); echo "### " . basename($_SERVER['SCRIPT_NAME']) . " Batch Converter\n\n"; echo "### Start: " . $date->get(Zend_Date::W3C) . "\n\n"; unset($date); // ----------------------------------------------------------------------------- if (is_file(FILENAME_LOCK)) { printf("ERROR: There is already an instance running (%s)\n", FILENAME_LOCK); // ------------------------------------------------------------------------- } else { $phpLiveDocx = new Tis_Service_LiveDocx_MailMerge(USERNAME, PASSWORD); $outputFormats = $phpLiveDocx->getDocumentFormats(); // ------------------------------------------------------------------------- $options = array('output-format|of=s' => sprintf('Output file format (%s).', implode(', ', $outputFormats))); try { $opts = new Zend_Console_Getopt($options); $opts->parse(); } catch (Zend_Console_Getopt_Exception $e) { echo $e->getUsageMessage(); exit; } $outputFormat = $opts->getOption('output-format'); $outputFormat = strtolower($outputFormat); if (!in_array($outputFormat, $outputFormats)) { echo $opts->getUsageMessage(); exit;
#!/usr/bin/php <?php require_once dirname(__FILE__) . '/../../common.php'; $date = new Zend_Date(); $date->setLocale(LOCALE); $phpLiveDocx = new Tis_Service_LiveDocx_MailMerge(USERNAME, PASSWORD); $phpLiveDocx->setLocalTemplate('template.doc'); $phpLiveDocx->assign('customer_number', sprintf("#%'10s\n", rand(0, 1000000000))); $phpLiveDocx->assign('invoice_number', sprintf("#%'10s\n", rand(0, 1000000000))); $phpLiveDocx->assign('account_number', sprintf("#%'10s\n", rand(0, 1000000000))); $billData = array('phone' => '+49 421 335 9000', 'date' => $date->get(Zend_Date::DATE_LONG), 'name' => 'James Henry Brown', 'service_phone' => '+49 421 335 910', 'service_fax' => '+49 421 335 9180', 'month' => sprintf('%s %s', $date->get(Zend_Date::MONTH_NAME), $date->get(Zend_Date::YEAR)), 'monthly_fee' => '€ 15.00', 'total_net' => '€ 100.00', 'tax' => '19%', 'tax_value' => '€ 15.00', 'total' => '€ 130.00'); $phpLiveDocx->assign($billData); $billConnections = array(array('connection_number' => '+49 421 335 912', 'connection_duration' => '00:00:07', 'fee' => '€ 0.03'), array('connection_number' => '+49 421 335 913', 'connection_duration' => '00:00:07', 'fee' => '€ 0.03'), array('connection_number' => '+49 421 335 914', 'connection_duration' => '00:00:07', 'fee' => '€ 0.03'), array('connection_number' => '+49 421 335 916', 'connection_duration' => '00:00:07', 'fee' => '€ 0.03')); $phpLiveDocx->assign('connection', $billConnections); $documentProperties = array('title' => sprintf('Telephone Invoice (%s)', $billData['name']), 'author' => 'TIS Telecom', 'subject' => sprintf('Your telephone invoice for %s', $billData['month']), 'keywords' => sprintf('Telephone, Payment, Invoice, %s', $billData['month'])); $phpLiveDocx->setDocumentProperties($documentProperties); $phpLiveDocx->createDocument(); $document = $phpLiveDocx->retrieveDocument('pdf'); unset($phpLiveDocx); file_put_contents('document.pdf', $document);
#!/usr/bin/php <?php require_once dirname(__FILE__) . '/../../common.php'; $date = new Zend_Date(); $date->setLocale(LOCALE); $phpLiveDocx = new Tis_Service_LiveDocx_MailMerge(USERNAME, PASSWORD); $phpLiveDocx->setLocalTemplate('template.docx'); $phpLiveDocx->assign('software', 'ACE Downloader 2.8'); $phpLiveDocx->assign('licensee', 'Paul Peterson'); $phpLiveDocx->assign('company', 'Bresoft Ltd'); $phpLiveDocx->assign('date', $date->get(Zend_Date::DATE_LONG)); $phpLiveDocx->assign('time', $date->get(Zend_Date::TIME_LONG)); $phpLiveDocx->assign('city', 'Royal Tunbridge Wells'); $phpLiveDocx->assign('country', 'United Kingdom'); $phpLiveDocx->createDocument(); foreach ($phpLiveDocx->getDocumentFormats() as $format) { $documentFile = sprintf('document.%s', $format); printf('Retrieving %s version (%s)... ', strtoupper($format), $documentFile); $document = $phpLiveDocx->retrieveDocument($format); file_put_contents($documentFile, $document); print "DONE.\n"; } unset($phpLiveDocx);
} if (isset($geoIp['CountryCode']) && strlen($geoIp['CountryCode']) > 0) { $countryCode = $geoIp['CountryCode']; $countries = Zend_Locale::getCountryTranslationList(LOCALE); if (isset($countries[$countryCode])) { $country = $countries[$countryCode]; } } } } catch (Zend_Http_Client_Exception $e) { } // ----------------------------------------------------------------------------- // Generate document $date = new Zend_Date(); $date->setLocale(LOCALE); $phpLiveDocx = new Tis_Service_LiveDocx_MailMerge(USERNAME, PASSWORD); $phpLiveDocx->setLocalTemplate('template.docx'); $phpLiveDocx->assign('software', 'Magic Graphical Compression Suite v1.9'); $phpLiveDocx->assign('licensee', 'Henry Döner-Meyer'); $phpLiveDocx->assign('company', 'Megasoft Co-operation'); $phpLiveDocx->assign('date', $date->get(Zend_Date::DATE_LONG)); $phpLiveDocx->assign('time', $date->get(Zend_Date::TIME_LONG)); $phpLiveDocx->assign('city', isset($city) ? $city : 'Berlin'); // use geoIP data (see above) or default $phpLiveDocx->assign('country', isset($country) ? $country : 'Germany'); $documentProperties = array('title' => 'License Agreement', 'author' => 'Megasoft Co-operation', 'subject' => 'Magic Graphical Compression Suite v1.9', 'keywords' => 'graphics, magical, compression, license'); $phpLiveDocx->setDocumentProperties($documentProperties); $phpLiveDocx->createDocument(); /* foreach ($phpLiveDocx->getDocumentFormats() as $documentFormat) { $document = $phpLiveDocx->retrieveDocument($documentFormat);
#!/usr/bin/php <?php require_once dirname(__FILE__) . '/../../common.php'; $phpLiveDocx = new Tis_Service_LiveDocx_MailMerge(USERNAME, PASSWORD); print 'Checking whether a template is available... '; if (true === $phpLiveDocx->templateExists('template-1.docx')) { print 'EXISTS. '; } else { print 'DOES NOT EXIST. '; } print "DONE\n";
#!/usr/bin/php <?php require_once dirname(__FILE__) . '/../../common.php'; $phpLiveDocx = new Tis_Service_LiveDocx_MailMerge(USERNAME, PASSWORD); // ----------------------------------------------------------------------------- $templateName = 'template-1-text-field.docx'; $phpLiveDocx->setLocalTemplate($templateName); printf("Field names in %s:\n", $templateName); $fieldNames = $phpLiveDocx->getFieldNames(); foreach ($fieldNames as $fieldName) { printf("- %s\n", $fieldName); } // ----------------------------------------------------------------------------- $templateName = 'template-2-text-fields.doc'; $phpLiveDocx->setLocalTemplate($templateName); printf("\nField names in %s:\n", $templateName); $fieldNames = $phpLiveDocx->getFieldNames(); foreach ($fieldNames as $fieldName) { printf("- %s\n", $fieldName); } // ----------------------------------------------------------------------------- $templateName = 'template-block-fields.doc'; $phpLiveDocx->setLocalTemplate($templateName); printf("\nField names in %s:\n", $templateName); $fieldNames = $phpLiveDocx->getFieldNames(); foreach ($fieldNames as $fieldName) { printf("- %s\n", $fieldName); } printf("\nBlock names in %s:\n", $templateName); $blockNames = $phpLiveDocx->getBlockNames(); foreach ($blockNames as $blockName) {
#!/usr/bin/php <?php require_once dirname(__FILE__) . '/../../common.php'; $phpLiveDocx = new Tis_Service_LiveDocx_MailMerge(USERNAME, PASSWORD); $counter = 1; foreach ($phpLiveDocx->listTemplates() as $result) { printf('%d) %s', $counter, $result['filename']); $template = $phpLiveDocx->downloadTemplate($result['filename']); file_put_contents('downloaded-' . $result['filename'], $template); print " - DOWNLOADED.\n"; $counter++; } unset($phpLiveDocx);
#!/usr/bin/php <?php require_once dirname(__FILE__) . '/../../common.php'; $phpLiveDocx = new Tis_Service_LiveDocx_MailMerge(USERNAME, PASSWORD); print listDecorator($phpLiveDocx->listTemplates()); unset($phpLiveDocx);