<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>LiveDocx in PHP &#187; Samples</title>
	<atom:link href="http://www.phplivedocx.org/category/samples/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.phplivedocx.org</link>
	<description>Zend Framework Implementation of LiveDocx</description>
	<lastBuildDate>Wed, 21 Dec 2011 12:39:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Video tutorial: Getting started with LiveDocx</title>
		<link>http://www.phplivedocx.org/2011/07/23/video-tutorial-getting-started-with-livedocx/</link>
		<comments>http://www.phplivedocx.org/2011/07/23/video-tutorial-getting-started-with-livedocx/#comments</comments>
		<pubDate>Sat, 23 Jul 2011 16:34:28 +0000</pubDate>
		<dc:creator>Jonathan Maron</dc:creator>
				<category><![CDATA[Community]]></category>
		<category><![CDATA[LiveDocx]]></category>
		<category><![CDATA[Samples]]></category>

		<guid isPermaLink="false">http://www.phplivedocx.org/?p=1453</guid>
		<description><![CDATA[Björn Meyer over at livedocx.com has just published a video (below) that illustrates how to set up a LiveDocx account, create a template with one merge field in Microsoft Word and finally how to populate the template, using a Visual Studio .NET based application. The final step of the tutorial is not directly relevant to [...]]]></description>
			<content:encoded><![CDATA[<p><em>Björn Meyer</em> over at livedocx.com has just published a <a href="http://www.youtube.com/watch?v=ZaVdYtnVIso">video</a> (below) that illustrates how to <a href="https://www.livedocx.com/user/account_registration.aspx">set up</a> a LiveDocx account, create a template with one merge field in Microsoft Word and finally how to populate the template, using a Visual Studio .NET based application.</p>
<p style="margin-bottom:15px;">The final step of the tutorial is not directly relevant to this blog, but the first two steps are. To see some PHP code that illustrates how to populate templates with LiveDocx, using the <a href="http://framework.zend.com/manual/en/zend.service.livedocx.html">Zend Framework</a>, please take a look at this article: <a href="http://www.phplivedocx.org/articles/brief-introduction-to-phplivedocx/">Brief introduction to LiveDocx in PHP</a>.</p>
<p><object width="560" height="450"><param name="movie" value="http://www.youtube.com/v/NW89ti-esVA?fs=1&amp;hl=en_US"></param><param name="allowFullScreen" value="true"></param><param name="allowScriptAccess" value="always"></param><param name="wmode" value="transparent"></param>
    <embed src="http://www.youtube.com/v/NW89ti-esVA?fs=1&amp;hl=en_US" type="application/x-shockwave-flash" allowScriptAccess="always" allowFullScreen="true" wmode="transparent" width="560" height="450"></embed></object></p>
<p style="margin-top:15px;">If you have any questions about the video or need help using LiveDocx, please do not hesitate to use the comment section below.</p>
<p>Thank you <em>Björn</em> for a very easy-to-follow video tutorial.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.phplivedocx.org/2011/07/23/video-tutorial-getting-started-with-livedocx/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Including Sub-Templates within a Template</title>
		<link>http://www.phplivedocx.org/2011/06/09/including-sub-templates-within-a-template/</link>
		<comments>http://www.phplivedocx.org/2011/06/09/including-sub-templates-within-a-template/#comments</comments>
		<pubDate>Thu, 09 Jun 2011 11:31:25 +0000</pubDate>
		<dc:creator>Jonathan Maron</dc:creator>
				<category><![CDATA[Community]]></category>
		<category><![CDATA[Samples]]></category>
		<category><![CDATA[Zend Framework]]></category>

		<guid isPermaLink="false">http://www.phplivedocx.org/?p=1412</guid>
		<description><![CDATA[An oft underestimated feature of LiveDocx is support for the Microsoft Word INCLUDETEXT field type, which allows templates to be chained together into one larger template. The entire contents of the sub-templates are brought into the main template in the order in which the fields are inserted, during the merge process. The final document contains [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.phplivedocx.org/wp-content/uploads/2011/06/subtemplates.png" width="560" height="350" alt="Sub-templates in Microsoft Word" title="Sub-templates in Microsoft Word" /></p>
<p>An oft underestimated feature of LiveDocx is support for the Microsoft Word INCLUDETEXT field type, which allows templates to be chained together into one larger template. The entire contents of the sub-templates are brought into the main template in the order in which the fields are inserted, during the merge process. The final document contains the contents of the template and all sub-templates.</p>
<p>To learn more about INCLUDETEXT and how to insert INCLUDETEXT fields into your template, please take a look the following articles:</p>
<ul>
<li><a href="http://support.microsoft.com/kb/253957">WD2000: How to Create a Long Document in Word</a>, Section <em>IncludeText Field</em></li>
</ul>
<ul>
<li><a href="http://blog.livedocx.com/post/Using-INCLUDETEXT-Fieldse28093Part-1-Creating-Templates.aspx">Using IncludeText Fields &#8211; Part 1: Creating Templates</a></li>
</ul>
<ul>
<li><a href="http://blog.livedocx.com/post/Using-INCLUDETEXT-Fieldse28093Part-2-Putting-It-All-To-Work.aspx">Using IncludeText Fields &#8211; Part 2: Putting It All To Work</a></li>
</ul>
<p><em>Zend\Service\LiveDocx\MailMerge</em> provides two methods to control how or whether sub-templates are included in the main template.</p>
<p>In the default state, all templates, which are referenced in INCLUDETEXT fields are included during the merge process.</p>
<p>If you do not want this to be the case, the method <em>setIgnoreSubTemplates()</em> can be set to <em>true</em>. This disables the inclusion of <strong>all</strong> sub-templates during the merge process. Using the <strong>free public</strong> LiveDocx service, you cannot selectively define which templates should be included. It is an all-or-nothing approach.</p>
<p>The <strong>premium</strong> and <strong>licensed</strong> versions of the LiveDocx service, on the other hand, allow for more fine grained control. These versions provide the method <em>setSubTemplateIgnoreList()</em>, which takes an array of filenames that should not be included. This way, you can, for example, included sub-templates 2 and 5, but not 1, 3 and 4.</p>
<p>The methods <em>setIgnoreSubTemplates()</em> and <em>setSubTemplateIgnoreList()</em> will be part of Zend Framework 2 when it ships. The latest code updates should be merged into <em>master</em> on the Zend canonical repository within the next few weeks. For the time being, the code is still in my GitHub repository, in the branch <em>livedocx-2.0</em>. </p>
<p>You can clone the latest code at:<br /><a href="https://github.com/jonathanmaron/zf2/tree/livedocx-2.0">https://github.com/jonathanmaron/zf2/tree/livedocx-2.0</a></p>
<p>Take a look at the <a href="https://github.com/jonathanmaron/zf2/tree/livedocx-2.0/demos/Zend/Service/LiveDocx/MailMerge/subtemplates">following directory</a> for some demonstration applications that illustrate the methods <em>setIgnoreSubTemplates()</em> and <em>setSubTemplateIgnoreList()</em></p>

<div class="wp_syntax"><div class="code"><pre class="bash">/demos/Zend/Service/LiveDocx/MailMerge/templates-ignore/</pre></div></div>

<p>Feel free to contact me, using the comments section below, if you need any help, or notice any inconsistencies in the code.</p>
<p style="padding: 5px; background-color: #EFEFEF;"><strong>June 10, 2011</strong>: The code updates mentioned in this post have now been merged into <em>master</em> on the Zend canonical repository.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.phplivedocx.org/2011/06/09/including-sub-templates-within-a-template/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>LiveDocx in Zend Framework 2 &#8211; an update</title>
		<link>http://www.phplivedocx.org/2011/05/26/livedocx-in-zend-framework-2-an-update/</link>
		<comments>http://www.phplivedocx.org/2011/05/26/livedocx-in-zend-framework-2-an-update/#comments</comments>
		<pubDate>Thu, 26 May 2011 08:59:10 +0000</pubDate>
		<dc:creator>Jonathan Maron</dc:creator>
				<category><![CDATA[Community]]></category>
		<category><![CDATA[Samples]]></category>
		<category><![CDATA[Zend Framework]]></category>

		<guid isPermaLink="false">http://www.phplivedocx.org/?p=1362</guid>
		<description><![CDATA[I am delighted to announce that the Zend Framework 2 implementation of the LiveDocx service is getting nearer completion. At the moment, the code is still in my GitHub repository, in the branch livedocx-2.0. It should be merged into master on the Zend canonical repository within the next few weeks. You can clone the latest [...]]]></description>
			<content:encoded><![CDATA[<p>I am delighted to announce that the Zend Framework 2 implementation of the LiveDocx service is getting nearer completion. At the moment, the code is still in my GitHub repository, in the branch <em>livedocx-2.0</em>. It should be merged into <em>master</em> on the Zend canonical repository within the next few weeks.</p>
<p>You can clone the latest code at:<br /><a href="https://github.com/jonathanmaron/zf2/tree/livedocx-2.0">https://github.com/jonathanmaron/zf2/tree/livedocx-2.0</a></p>
<p><strong>What&#8217;s new in this version?</strong></p>
<ul>
<li>Exception handling has been migrated to ZF2 practices i.e. <em>Exception/RuntimeException</em> and <em>Exception/InvalidArgumentException</em>.</li>
</ul>
<ul>
<li>Exceptions from the backend service now contain <strong>only</strong> the message from the backend service. The backend engineers requested this be the case, as it aides support cases.</li>
</ul>
<ul>
<li>The inline documentation has been updated.</li>
</ul>
<ul>
<li>The methods <em>logIn()</em> and <em>logOut()</em> are now <em>protected</em> in scope.</li>
</ul>
<ul>
<li>The methods <em>setIsLoggedIn()</em> and <em>getIsLoggedIn()</em> were added.</li>
</ul>
<ul>
<li>The quality and coverage of unit tests have been vastly improved (63 tests, 203 assertions).</li>
</ul>
<p>You are welcome to clone the repository and try out the new code for yourself. Feel free to contact me, using the comments section below, if you need any help, or notice any inconsistencies in the code.</p>
<p style="padding: 5px; background-color: #EFEFEF;"><strong>June 10, 2011</strong>: The code updates mentioned in this post have now been merged into <em>master</em> on the Zend canonical repository.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.phplivedocx.org/2011/05/26/livedocx-in-zend-framework-2-an-update/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Generating 1000s of concatenated documents</title>
		<link>http://www.phplivedocx.org/2009/11/04/generating-1000s-of-concatenated-documents/</link>
		<comments>http://www.phplivedocx.org/2009/11/04/generating-1000s-of-concatenated-documents/#comments</comments>
		<pubDate>Wed, 04 Nov 2009 10:09:08 +0000</pubDate>
		<dc:creator>Jonathan Maron</dc:creator>
				<category><![CDATA[Samples]]></category>
		<category><![CDATA[Zend Framework]]></category>

		<guid isPermaLink="false">http://www.phplivedocx.org/?p=1063</guid>
		<description><![CDATA[There are applications in which thousands of populated templates need to be concatenated into one PDF file. Consider, for example, the case of a telephone company, wishing to generate an invoice for all its customers. Such a scenario can be split up into two separate and distinct processes: invoice generation and invoice printing. LiveDocx is [...]]]></description>
			<content:encoded><![CDATA[<p>There are applications in which thousands of populated templates need to be concatenated into one PDF file. Consider, for example, the case of a telephone company, wishing to generate an invoice for all its customers. Such a scenario can be split up into two separate and distinct processes: <em>invoice generation</em> and <em>invoice printing</em>.</p>
<p>LiveDocx is the tool of choice for the invoice generation process. But how do you efficiently get a printed copy of the invoices to the customer? One way would be to concatenate all the created invoices into one massive PDF file and then dispatch this PDF file to the printers.</p>
<h3>Backend concatenation</h3>
<p>As of LiveDocx 1.2, it has been possible to assign multiple records in the form of a nested associative array to a template. The result is one concatenated document, containing the populated template (one per nested sub-array).</p>
<p>This backend concatenation approach is a fantastic way to create hundreds of documents in one run, but in the case that your application demands thousands or even tens of thousands of documents, the amount of data that has be transfered via SOAP in one request does get extremely large and depending upon your Internet connection, can become a little slow and consequently burdensome.</p>
<p>This blog post offers a new approach to generate documents using LiveDocx on the backend, but perform the concatenation locally. The following screenshot illustrates the sample application in action (click to zoom):</p>
<p style="background-color:#000000;"><a href="http://www.phplivedocx.org/wp-content/uploads/2009/11/livedocx-local-concatenation_zoom.png"><img src="http://www.phplivedocx.org/wp-content/uploads/2009/11/livedocx-local-concatenation.png" /></a></p>
<p>The code has been written for the official <em>Zend_Service_LiveDocx_MailMerge</em> component, which is currently in the <a href="http://www.phplivedocx.org/2009/12/03/migrated-to-zend-framework-standard-trunk/">Standard Trunk</a>. By modifying the constructor, however, you can easily make it work with <em>Tis_Service_Service_MailMerge</em>.</p>
<h3>Generate remotely, concatenate locally</h3>
<p>In the sample application, documents are created by the backend LiveDocx server and concatenated locally, using either <a href="http://www.accesspdf.com/pdftk/">pdftk</a> or <a href="http://pages.cs.wisc.edu/~ghost/">Ghostscript</a> in the function <em>concatenatePdfFilenames()</em>. This approach has the advantage that only the singular documents are transfered from the backend LiveDocx service via SOAP to the server and not the entire concatenated document, which theoretically can be many gigabytes in size. The disadvantage, of course, is that one or these tools must be installed on the local server. However, as both are open source and available for Windows and Linux, this should not pose such a problem. Often they will already be installed on your server.</p>
<p>If both <a href="http://www.accesspdf.com/pdftk/">pdftk</a> and <a href="http://pages.cs.wisc.edu/~ghost/">Ghostscript</a> are available, it is recommended to use <a href="http://www.accesspdf.com/pdftk/">pdftk</a>, as it is considerably faster and uses less memory. <a href="http://pages.cs.wisc.edu/~ghost/">Ghostscript</a>, on the other hand, generates slightly small PDF files.</p>
<h3>Try it out yourself</h3>
<p>The source code to this sample application is located at <em>/demos/Zend/Service/LiveDocx/MailMerge/license-agreement/generate-document-concat.php</em> of the <a href="http://www.phplivedocx.org/2009/12/03/migrated-to-zend-framework-standard-trunk/">Standard Trunk</a>. Simply checkout the entire repository or update your local working copy. If you are just curious about what the code looks like, you can view the source code here: <a href="http://framework.zend.com/svn/framework/standard/trunk/demos/Zend/Service/LiveDocx/MailMerge/license-agreement/generate-document-concat.php">generate-document-concat.php</a>.</p>
<p>If you have any questions about this local concatenation approach, please post into the comments below.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.phplivedocx.org/2009/11/04/generating-1000s-of-concatenated-documents/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Convert DOCX, DOC &amp; RTF to HTML in PHP</title>
		<link>http://www.phplivedocx.org/2009/08/13/convert-docx-doc-rtf-to-html-in-php/</link>
		<comments>http://www.phplivedocx.org/2009/08/13/convert-docx-doc-rtf-to-html-in-php/#comments</comments>
		<pubDate>Thu, 13 Aug 2009 05:41:43 +0000</pubDate>
		<dc:creator>Jonathan Maron</dc:creator>
				<category><![CDATA[Samples]]></category>

		<guid isPermaLink="false">http://www.phplivedocx.org/?p=832</guid>
		<description><![CDATA[As of phpLiveDocx 1.2, it is possible to generate documents in XHTML 1.0 Transitional. Thus, you can now convert any supported template file format (DOCX, DOC and RTF) to XHTML. Consider the following example (discussion under the code): 1 2 3 4 5 6 7 8 9 10 11 12 13 14 $mailMerge = new [...]]]></description>
			<content:encoded><![CDATA[<p>As of phpLiveDocx 1.2, it is possible to generate documents in <a href="http://www.w3.org/TR/xhtml1/">XHTML 1.0 Transitional</a>. Thus, you can now <a href="http://www.phplivedocx.org/2009/02/06/convert-doc-to-pdf-in-php/">convert</a> any supported <a href="http://www.phplivedocx.org/2009/01/12/supported-file-formats-in-phplivedocx/">template file format</a> (DOCX, DOC and RTF) to XHTML.</p>
<p>Consider the following example (discussion under the code):</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="code"><pre class="php"><span style="color: #0000ff;">$mailMerge</span> = <span style="color: #000000; font-weight: bold;">new</span> Zend_Service_LiveDocx_MailMerge<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #0000ff;">$mailMerge</span>-&gt;<span style="color: #006600;">setUsername</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'myUsername'</span><span style="color: #66cc66;">&#41;</span>
          -&gt;<span style="color: #006600;">setPassword</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'myPassword'</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #0000ff;">$mailMerge</span>-&gt;<span style="color: #006600;">setLocalTemplate</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'license-agreement.doc'</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #0000ff;">$mailMerge</span>-&gt;<span style="color: #006600;">assign</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span>;  <span style="color: #008080; font-style: italic;">// must be called as of phpLiveDocx 1.2</span>
&nbsp;
<span style="color: #0000ff;">$mailMerge</span>-&gt;<span style="color: #006600;">createDocument</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #0000ff;">$data</span> = <span style="color: #0000ff;">$mailMerge</span>-&gt;<span style="color: #006600;">retrieveDocument</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'html'</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
file_put_contents<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'./license-agreement.htm'</span>, <span style="color: #0000ff;">$data</span><span style="color: #66cc66;">&#41;</span>;</pre></td></tr></table></div>

<p>We specify the document we want to to convert and then simply retrieve the document in the required format &#8211; XHTML in this case.</p>
<p>Please download the <a href="http://www.phplivedocx.org/wp-content/uploads/2009/08/license-agreement.doc">source document</a> and <a href="http://www.phplivedocx.org/wp-content/uploads/2009/08/license-agreement.zip">converted document</a> and take a look at the source code of the created HTML file.</p>
<p>You will see that the logo at the top left of the page is not linked in, as you may expect, but has been embedded in the HTML file, using the <a href="http://en.wikipedia.org/wiki/Data_URI_scheme">data URI scheme</a> method. The markup to look out for is as follows:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="html4strict"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;img</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;data:image/png;base64,
iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAABGdBTUEAALGPC/xhBQAAAAlwSFlz
AAALEwAACxMBAJqcGAAAAAd0SU1FB9YGARc5KB0XV+IAAAAddEVYdENvbW1lbnQAQ3JlYXRlZCB3
aXRoIFRoZSBHSU1Q72QlbgAAAF1JREFUGNO9zL0NglAAxPEfdLTs4BZM4DIO4C7OwQg2JoQ9LE1e
xdlYvBBeZ7jqch9//q1uH4TLzw4d6+ErXMMcXuHWxId3KOETnnXXV6MJpcq2MLaI97CER3N0vr4M
khoXe0rZigAAAABJRU5ErkJggg==&quot;</span> <span style="color: #000066;">alt</span>=<span style="color: #ff0000;">&quot;&quot;</span> /<span style="color: #000000; font-weight: bold;">&gt;</span></span></pre></td></tr></table></div>

<p>The main advantage of this embedded approach is that a request is not required to download the image file; hence, it is easier to share the document around, in particular, if the recipient is not connected to a network when viewing the file.</p>
<p>The Wikipedia article offers a detailed discussion on the <a href="http://en.wikipedia.org/wiki/Data_URI_scheme#Advantages">advantages</a> and <a href="http://en.wikipedia.org/wiki/Data_URI_scheme#Disadvantages">disadvantages</a> of the <em>data URI scheme</em> approach.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.phplivedocx.org/2009/08/13/convert-docx-doc-rtf-to-html-in-php/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Appending documents in phpLiveDocx 1.2</title>
		<link>http://www.phplivedocx.org/2009/08/12/appending-documents-in-phplivedocx-1-2/</link>
		<comments>http://www.phplivedocx.org/2009/08/12/appending-documents-in-phplivedocx-1-2/#comments</comments>
		<pubDate>Wed, 12 Aug 2009 08:15:56 +0000</pubDate>
		<dc:creator>Jonathan Maron</dc:creator>
				<category><![CDATA[Samples]]></category>

		<guid isPermaLink="false">http://www.phplivedocx.org/?p=823</guid>
		<description><![CDATA[Another useful feature of phpLiveDocx 1.2, is the ability to append one document to another. All you have to do is assign multiple sets of data to phpLiveDocx, in the form of a multi-depth associative array (see below). Each sub array (see set 1, set 2 etc.) is used to to create one document. Each [...]]]></description>
			<content:encoded><![CDATA[<p>Another useful feature of phpLiveDocx 1.2, is the ability to append one document to another. All you have to do is assign multiple sets of data to phpLiveDocx, in the form of a multi-depth associative array (see below). Each sub array (see <em>set 1</em>, <em>set 2</em> etc.) is used to to create one document. Each newly created document is appended to the previous one.</p>
<p>Sound complicated? It is not!</p>
<p>First of all, download <em><a href="http://www.phplivedocx.org/wp-content/uploads/2009/08/append-template.docx">append-template.docx</a></em>. Then run the following code. The result is one file <em><a href="http://www.phplivedocx.org/wp-content/uploads/2009/08/append-document.pdf">append-document.pdf</a></em>, which contains 4 pages. Once page per set of data.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
</pre></td><td class="code"><pre class="php"><span style="color: #0000ff;">$mailMerge</span> = <span style="color: #000000; font-weight: bold;">new</span> Zend_Service_LiveDocx_MailMerge<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #0000ff;">$mailMerge</span>-&gt;<span style="color: #006600;">setUsername</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'myUsername'</span><span style="color: #66cc66;">&#41;</span>
          -&gt;<span style="color: #006600;">setPassword</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'myPassword'</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #0000ff;">$mailMerge</span>-&gt;<span style="color: #006600;">setLocalTemplate</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'./append-template.docx'</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #0000ff;">$fieldValues</span> = <span style="color: #000066;">array</span> <span style="color: #66cc66;">&#40;</span>
    <span style="color: #008080; font-style: italic;">// set 1</span>
    <span style="color: #000066;">array</span> <span style="color: #66cc66;">&#40;</span>
        <span style="color: #ff0000;">'software'</span> =&gt; <span style="color: #ff0000;">'Magic Graphical Compression Suite v2.5'</span>,
        <span style="color: #ff0000;">'name'</span>     =&gt; <span style="color: #ff0000;">'Henry Richards'</span>
    <span style="color: #66cc66;">&#41;</span>,
    <span style="color: #008080; font-style: italic;">// set 2</span>
    <span style="color: #000066;">array</span> <span style="color: #66cc66;">&#40;</span>
        <span style="color: #ff0000;">'software'</span> =&gt; <span style="color: #ff0000;">'Magic CAD Suite v1.9'</span>,
        <span style="color: #ff0000;">'name'</span>     =&gt; <span style="color: #ff0000;">'Brüno Cassidy'</span>
    <span style="color: #66cc66;">&#41;</span>,
    <span style="color: #008080; font-style: italic;">// set 3</span>
    <span style="color: #000066;">array</span> <span style="color: #66cc66;">&#40;</span>
        <span style="color: #ff0000;">'software'</span> =&gt; <span style="color: #ff0000;">'Super Ray Tracer 19.2'</span>,
        <span style="color: #ff0000;">'name'</span>     =&gt; <span style="color: #ff0000;">'Paul Roberts'</span>
    <span style="color: #66cc66;">&#41;</span>,
    <span style="color: #008080; font-style: italic;">// set 4</span>
    <span style="color: #000066;">array</span> <span style="color: #66cc66;">&#40;</span>
        <span style="color: #ff0000;">'software'</span> =&gt; <span style="color: #ff0000;">'Random File Downloader 0.1a'</span>,
        <span style="color: #ff0000;">'name'</span>     =&gt; <span style="color: #ff0000;">'Kay Sandler'</span>
    <span style="color: #66cc66;">&#41;</span>                    
<span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #0000ff;">$mailMerge</span>-&gt;<span style="color: #006600;">assign</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$fieldValues</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #0000ff;">$mailMerge</span>-&gt;<span style="color: #006600;">createDocument</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #0000ff;">$data</span> = <span style="color: #0000ff;">$mailMerge</span>-&gt;<span style="color: #006600;">retrieveDocument</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'pdf'</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
file_put_contents<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'./append-document.pdf'</span>, <span style="color: #0000ff;">$data</span><span style="color: #66cc66;">&#41;</span>;</pre></td></tr></table></div>

<p>This is a very simple sample, with a very simple template. However, this functionality is especially useful for scenarios, such as label printing and voucher or certificate creation.</p>
<p>If you need any help, please do not hesitate to post into the <a href="http://www.phplivedocx.org/support/">support forum</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.phplivedocx.org/2009/08/12/appending-documents-in-phplivedocx-1-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Generate bitmap image files in phpLiveDocx 1.2</title>
		<link>http://www.phplivedocx.org/2009/08/11/generate-bitmap-image-files-in-phplivedocx-1-2/</link>
		<comments>http://www.phplivedocx.org/2009/08/11/generate-bitmap-image-files-in-phplivedocx-1-2/#comments</comments>
		<pubDate>Tue, 11 Aug 2009 05:38:26 +0000</pubDate>
		<dc:creator>Jonathan Maron</dc:creator>
				<category><![CDATA[Samples]]></category>

		<guid isPermaLink="false">http://www.phplivedocx.org/?p=807</guid>
		<description><![CDATA[One of the neatest new features in phpLiveDocx 1.2, which was officially launched yesterday, is the ability to save a document to a number of image files (one image file per page of the document). In addition to the supported document file formats, phpLiveDocx 1.2 can now save documents as BMP, GIF, JPG, PNG and [...]]]></description>
			<content:encoded><![CDATA[<p>One of the neatest new features in phpLiveDocx 1.2, which was <a href="http://www.phplivedocx.org/2009/08/10/livedocx-1-2-has-been-released/">officially launched</a> yesterday, is the ability to save a document to a number of image files (one image file per page of the document).</p>
<p>In addition to the supported <a href="http://www.phplivedocx.org/2009/01/12/supported-file-formats-in-phplivedocx/">document file formats</a>, phpLiveDocx 1.2 can now save documents as <a href="http://en.wikipedia.org/wiki/BMP_file_format">BMP</a>, <a href="http://en.wikipedia.org/wiki/GIF">GIF</a>, <a href="http://en.wikipedia.org/wiki/Jpg">JPG</a>, <a href="http://en.wikipedia.org/wiki/Portable_Network_Graphics">PNG</a> and <a href="http://en.wikipedia.org/wiki/Tagged_Image_File_Format">TIFF</a>.</p>
<p>In the latest <a href="http://www.phplivedocx.org/downloads/">distribution file</a>, in the directory <em>/samples/mail-merge/bitmaps</em>, you will find the following sample. The new methods to look out for are <em>getAllBitmaps($zoomFactor, $format)</em> and <em>getBitmaps($fromPage, $toPage, $zoomFactor, $format)</em>.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
</pre></td><td class="code"><pre class="php"><span style="color: #0000ff;">$mailMerge</span> = <span style="color: #000000; font-weight: bold;">new</span> Zend_Service_LiveDocx_MailMerge<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #0000ff;">$mailMerge</span>-&gt;<span style="color: #006600;">setUsername</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'myUsername'</span><span style="color: #66cc66;">&#41;</span>
          -&gt;<span style="color: #006600;">setPassword</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'myPassword'</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #0000ff;">$mailMerge</span>-&gt;<span style="color: #006600;">setLocalTemplate</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'template.docx'</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #0000ff;">$mailMerge</span>-&gt;<span style="color: #006600;">assign</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'software'</span>, <span style="color: #ff0000;">'Magic Graphical Compression Suite v1.9'</span><span style="color: #66cc66;">&#41;</span>
          -&gt;<span style="color: #006600;">assign</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'licensee'</span>, <span style="color: #ff0000;">'Henry Döner-Meyer'</span><span style="color: #66cc66;">&#41;</span>
          -&gt;<span style="color: #006600;">assign</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'company'</span>,  <span style="color: #ff0000;">'Co-Operation'</span><span style="color: #66cc66;">&#41;</span>
          -&gt;<span style="color: #006600;">assign</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'date'</span>,     <span style="color: #ff0000;">'January 11, 2010'</span><span style="color: #66cc66;">&#41;</span>
          -&gt;<span style="color: #006600;">assign</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'time'</span>,     <span style="color: #ff0000;">'January 11, 2010'</span><span style="color: #66cc66;">&#41;</span>
          -&gt;<span style="color: #006600;">assign</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'city'</span>,     <span style="color: #ff0000;">'Berlin'</span><span style="color: #66cc66;">&#41;</span>
          -&gt;<span style="color: #006600;">assign</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'country'</span>,  <span style="color: #ff0000;">'Germany'</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #0000ff;">$mailMerge</span>-&gt;<span style="color: #006600;">createDocument</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #008080; font-style: italic;">// Get all bitmaps</span>
<span style="color: #0000ff;">$bitmaps</span> = <span style="color: #0000ff;">$mailMerge</span>-&gt;<span style="color: #006600;">getAllBitmaps</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">100</span>, <span style="color: #ff0000;">'png'</span><span style="color: #66cc66;">&#41;</span>;      <span style="color: #008080; font-style: italic;">// zoomFactor, format</span>
&nbsp;
<span style="color: #008080; font-style: italic;">// Get just bitmaps in specified range</span>
<span style="color: #008080; font-style: italic;">//$bitmaps = $mailMerge-&gt;getBitmaps(2, 2, 100, 'png');   // fromPage, toPage, zoomFactor, format</span>
&nbsp;
<span style="color: #b1b100;">foreach</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$bitmaps</span> <span style="color: #b1b100;">as</span> <span style="color: #0000ff;">$pageNumber</span> =&gt; <span style="color: #0000ff;">$bitmapData</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    <span style="color: #0000ff;">$filename</span> = <span style="color: #000066;">sprintf</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'documentPage%d.png'</span>, <span style="color: #0000ff;">$pageNumber</span><span style="color: #66cc66;">&#41;</span>;
    file_put_contents<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$filename</span>, <span style="color: #0000ff;">$bitmapData</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #000066;">unset</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$mailMerge</span><span style="color: #66cc66;">&#41;</span>;</pre></td></tr></table></div>

<p>This produces the following two files (<em>documentPage1.png</em> and <em>documentPage2.png</em>) and writes them to disk in the same directory as the executable PHP code (click to enlarge):</p>
<p><a href="http://www.phplivedocx.org/wp-content/uploads/2009/08/bitmaps-document-page-1_zoom.png"><img src="http://www.phplivedocx.org/wp-content/uploads/2009/08/bitmaps-document-page-1.png" width="280" height="362" alt="documentPage1.png" title="documentPage1.png" /></a><a href="http://www.phplivedocx.org/wp-content/uploads/2009/08/bitmaps-document-page-2_zoom.png"><img src="http://www.phplivedocx.org/wp-content/uploads/2009/08/bitmaps-document-page-2.png" width="280" height="362" alt="documentPage2.png" title="documentPage2.png" /></a></p>
<p>To try this out for yourself, you will need to update to <a href="http://www.phplivedocx.org/downloads/">phplivedocx-1.2-20090810</a> or newer.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.phplivedocx.org/2009/08/11/generate-bitmap-image-files-in-phplivedocx-1-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using LiveDocx without the Zend Framework</title>
		<link>http://www.phplivedocx.org/2009/08/10/using-livedocx-without-the-zend-framework/</link>
		<comments>http://www.phplivedocx.org/2009/08/10/using-livedocx-without-the-zend-framework/#comments</comments>
		<pubDate>Mon, 10 Aug 2009 08:20:51 +0000</pubDate>
		<dc:creator>Jonathan Maron</dc:creator>
				<category><![CDATA[Samples]]></category>

		<guid isPermaLink="false">http://www.phplivedocx.org/?p=766</guid>
		<description><![CDATA[We have received a considerable number of requests from developers, asking whether it is possible to deploy LiveDocx in PHP without the Zend Framework. Yes. Indeed, it is. I have just published a couple of sample applications and a brief article, which show how: Using phpLiveDocx without the Zend Framework]]></description>
			<content:encoded><![CDATA[<p>We have received a considerable number of requests from developers, asking whether it is possible to deploy LiveDocx in PHP without the Zend Framework.</p>
<p><strong>Yes. Indeed, it is.</strong></p>
<p>I have just published a couple of sample applications and a brief article, which show how:</p>
<ul>
<li><a href="http://www.phplivedocx.org/articles/using-livedocx-without-the-zend-framework/">Using phpLiveDocx without the Zend Framework</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.phplivedocx.org/2009/08/10/using-livedocx-without-the-zend-framework/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Checking your LiveDocx compatibility</title>
		<link>http://www.phplivedocx.org/2009/07/30/checking-your-phplivedocx-compatibility/</link>
		<comments>http://www.phplivedocx.org/2009/07/30/checking-your-phplivedocx-compatibility/#comments</comments>
		<pubDate>Thu, 30 Jul 2009 12:41:28 +0000</pubDate>
		<dc:creator>Jonathan Maron</dc:creator>
				<category><![CDATA[Samples]]></category>

		<guid isPermaLink="false">http://www.phplivedocx.org/?p=715</guid>
		<description><![CDATA[About fifty percent of the support requests we receive originate from the fact that the client&#8217;s server upon which LiveDocx is running is not set up correctly. To better debug such issues, we have just released a script which can be run from the command line to check that a server environment is compatible to [...]]]></description>
			<content:encoded><![CDATA[<p>About fifty percent of the support requests we receive originate from the fact that the client&#8217;s server upon which LiveDocx is running is not set up correctly.</p>
<p>To better debug such issues, we have just released a script which can be run from the command line to check that a server environment is compatible to LiveDocx.</p>
<p>The script <em><strong>check-environment.php</strong></em> is contained in the directory <em><strong>/demos/Zend/Service/LiveDocx/</strong></em>.</p>
<p>In the case that your environment is compatible to LiveDocx, you will see the following:</p>

<div class="wp_syntax"><div class="code"><pre class="bash">LiveDocx Environment Checker
&nbsp;
 <span style="color: #cc66cc;">1</span>: Checking OS <span style="color: #66cc66;">&#40;</span>Linux<span style="color: #66cc66;">&#41;</span>..................................................PASS
 <span style="color: #cc66cc;">2</span>: Checking SAPI <span style="color: #66cc66;">&#40;</span>cli<span style="color: #66cc66;">&#41;</span>..................................................PASS
 <span style="color: #cc66cc;">3</span>: Checking PHP version <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">5.2</span><span style="color: #cc66cc;">.9</span><span style="color: #66cc66;">&#41;</span>.........................................PASS
 <span style="color: #cc66cc;">4</span>: Checking HTTP stream wrapper.........................................PASS
 <span style="color: #cc66cc;">5</span>: Checking HTTPS stream wrapper........................................PASS
 <span style="color: #cc66cc;">6</span>: Checking Zend Framework path.........................................PASS
 <span style="color: #cc66cc;">7</span>: Checking Zend Framework version <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1.9</span><span style="color: #cc66cc;">.0</span><span style="color: #66cc66;">&#41;</span>..............................PASS
 <span style="color: #cc66cc;">8</span>: Checking SOAP extension..............................................PASS
 <span style="color: #cc66cc;">9</span>: Checking DOM extension...............................................PASS
<span style="color: #cc66cc;">10</span>: Checking SimpleXML extension.........................................PASS
<span style="color: #cc66cc;">11</span>: Checking libXML extension............................................PASS
<span style="color: #cc66cc;">12</span>: Checking your IP address <span style="color: #66cc66;">&#40;</span>xxx.xxx.xxx.xxx<span style="color: #66cc66;">&#41;</span>...........................PASS
<span style="color: #cc66cc;">13</span>: Checking your city <span style="color: #66cc66;">&#40;</span>Berlin<span style="color: #66cc66;">&#41;</span>..........................................PASS
<span style="color: #cc66cc;">14</span>: Checking your region <span style="color: #66cc66;">&#40;</span>Berlin<span style="color: #66cc66;">&#41;</span>........................................PASS
<span style="color: #cc66cc;">15</span>: Checking your country <span style="color: #66cc66;">&#40;</span>Germany<span style="color: #66cc66;">&#41;</span>......................................PASS
<span style="color: #cc66cc;">16</span>: Checking backend WSDL <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span>.843467950821s<span style="color: #66cc66;">&#41;</span>..............................PASS
<span style="color: #cc66cc;">17</span>: Checking backend credentials are defined.............................PASS
<span style="color: #cc66cc;">18</span>: Instantiating Zend_Service_LiveDocx_MailMerge object <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span>.14s<span style="color: #66cc66;">&#41;</span>.........PASS
&nbsp;
Congratulations! All tests passed. The server environment, <span style="color: #b1b100;">in</span> which this script
is running, is suitable <span style="color: #b1b100;">for</span> LiveDocx.</pre></div></div>

<p>In the case that you do not have the Zend Framework correctly installed, you will see the following:</p>

<div class="wp_syntax"><div class="code"><pre class="bash">LiveDocx Environment Checker
&nbsp;
 <span style="color: #cc66cc;">1</span>: Checking OS <span style="color: #66cc66;">&#40;</span>Linux<span style="color: #66cc66;">&#41;</span>..................................................PASS
 <span style="color: #cc66cc;">2</span>: Checking SAPI <span style="color: #66cc66;">&#40;</span>cli<span style="color: #66cc66;">&#41;</span>..................................................PASS
 <span style="color: #cc66cc;">3</span>: Checking PHP version <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">5.2</span><span style="color: #cc66cc;">.9</span><span style="color: #66cc66;">&#41;</span>.........................................PASS
 <span style="color: #cc66cc;">4</span>: Checking HTTP stream wrapper.........................................PASS
 <span style="color: #cc66cc;">5</span>: Checking HTTPS stream wrapper........................................PASS
 <span style="color: #cc66cc;">6</span>: Checking Zend Framework path.........................................FAIL
&nbsp;
<span style="color: #66cc66;">&#91;</span>...<span style="color: #66cc66;">&#93;</span></pre></div></div>

<p>In the case that your username and/or password to LiveDocx is invalid, you will see the following:</p>

<div class="wp_syntax"><div class="code"><pre class="bash">LiveDocx Environment Checker
&nbsp;
 <span style="color: #cc66cc;">1</span>: Checking OS <span style="color: #66cc66;">&#40;</span>Linux<span style="color: #66cc66;">&#41;</span>..................................................PASS
 <span style="color: #cc66cc;">2</span>: Checking SAPI <span style="color: #66cc66;">&#40;</span>cli<span style="color: #66cc66;">&#41;</span>..................................................PASS
 <span style="color: #cc66cc;">3</span>: Checking PHP version <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">5.2</span><span style="color: #cc66cc;">.9</span><span style="color: #66cc66;">&#41;</span>.........................................PASS
 <span style="color: #cc66cc;">4</span>: Checking HTTP stream wrapper.........................................PASS
 <span style="color: #cc66cc;">5</span>: Checking HTTPS stream wrapper........................................PASS
 <span style="color: #cc66cc;">6</span>: Checking Zend Framework path.........................................PASS
 <span style="color: #cc66cc;">7</span>: Checking Zend Framework version <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1.9</span><span style="color: #cc66cc;">.0</span><span style="color: #66cc66;">&#41;</span>..............................PASS
 <span style="color: #cc66cc;">8</span>: Checking SOAP extension..............................................PASS
 <span style="color: #cc66cc;">9</span>: Checking DOM extension...............................................PASS
<span style="color: #cc66cc;">10</span>: Checking SimpleXML extension.........................................PASS
<span style="color: #cc66cc;">11</span>: Checking libXML extension............................................PASS
<span style="color: #cc66cc;">12</span>: Checking your IP address <span style="color: #66cc66;">&#40;</span>xxx.xxx.xxx.xxx<span style="color: #66cc66;">&#41;</span>...........................PASS
<span style="color: #cc66cc;">13</span>: Checking your city <span style="color: #66cc66;">&#40;</span>Berlin<span style="color: #66cc66;">&#41;</span>..........................................PASS
<span style="color: #cc66cc;">14</span>: Checking your region <span style="color: #66cc66;">&#40;</span>Berlin<span style="color: #66cc66;">&#41;</span>........................................PASS
<span style="color: #cc66cc;">15</span>: Checking your country <span style="color: #66cc66;">&#40;</span>Germany<span style="color: #66cc66;">&#41;</span>......................................PASS
<span style="color: #cc66cc;">16</span>: Checking backend WSDL <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span>.38575911522s<span style="color: #66cc66;">&#41;</span>...............................PASS
<span style="color: #cc66cc;">17</span>: Checking backend credentials are defined.............................PASS
<span style="color: #cc66cc;">18</span>: Instantiating Zend_Service_LiveDocx_MailMerge object <span style="color: #66cc66;">&#40;</span>-1s<span style="color: #66cc66;">&#41;</span>...........FAIL
&nbsp;
One or more tests failed. The web server environment, <span style="color: #b1b100;">in</span> which this script is
running, does not meet the requirements <span style="color: #b1b100;">for</span> LiveDocx.</pre></div></div>

<p>If you are having trouble getting started with LiveDocx, I would suggest you <a href="http://www.zendframework.com/download/latest">download</a> the latest Zend Framework and try out the <em>check-environment.php</em> script.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.phplivedocx.org/2009/07/30/checking-your-phplivedocx-compatibility/feed/</wfw:commentRss>
		<slash:comments>46</slash:comments>
		</item>
		<item>
		<title>Batch converter sample application</title>
		<link>http://www.phplivedocx.org/2009/05/15/batch-converter-sample-application/</link>
		<comments>http://www.phplivedocx.org/2009/05/15/batch-converter-sample-application/#comments</comments>
		<pubDate>Fri, 15 May 2009 12:37:05 +0000</pubDate>
		<dc:creator>Jonathan Maron</dc:creator>
				<category><![CDATA[Samples]]></category>

		<guid isPermaLink="false">http://www.phplivedocx.org/?p=683</guid>
		<description><![CDATA[In a typical office environment word processing documents are received via e-mail in a number of different formats. This phpLiveDocx sample application illustrates how to automatically convert files between any supported format (see below). All end-users have to do, is copy the documents they wish to convert into a specific network directory (aka Hot Folder) [...]]]></description>
			<content:encoded><![CDATA[<p>In a typical office environment word processing documents are received via e-mail in a number of different formats. This phpLiveDocx sample application illustrates how to automatically convert files between any supported format (see below).</p>
<p>All end-users have to do, is copy the documents they wish to convert into a specific network directory (aka <em>Hot Folder</em>) and the files are converted in a matter of minutes into the desired format. End-users can than pick up the converted documents and process them further, send them via e-mail or to the printer.</p>
<p>Consider the following screenshot of a typical Windows desktop (click to enlarge). The top window is the directory, which contains the files to convert. Once they have been converted the files are moved into the middle directory. The actual converted files are saved in the bottom window.</p>
<p><a href="http://www.phplivedocx.org/wp-content/uploads/2009/05/phplivedocx-convert-batch-desktop_zoom.png"><img src="http://www.phplivedocx.org/wp-content/uploads/2009/05/phplivedocx-convert-batch-desktop.png" width="560" height="448" /></a></p>
<h2>Supported file formats</h2>
<p>The following input file formats are supported:</p>
<ul>
<li>DOCX &#8211; Office Open XML Format</li>
<li>DOC &#8211; Microsoft Word DOC Format</li>
<li>RTF &#8211; Rich Text File Format</li>
<li>TXD &#8211; TX Text Control Format</li>
</ul>
<p>The following output file formats are supported:</p>
<ul>
<li>DOCX &#8211; Office Open XML Format</li>
<li>DOC &#8211; Microsoft Word DOC Format</li>
<li>HTML &#8211; XHTML 1.0 Transitional Format</li>
<li>RTF &#8211; Rich Text File Format</li>
<li>PDF &#8211; Acrobat Portable Document Format</li>
<li>TXD &#8211; TX Text Control Format</li>
<li>TXT &#8211; ANSI Plain Text</li>
</ul>
<h2>Getting started</h2>
<p><a href="http://www.phplivedocx.org/downloads/">Download</a> the current phpLiveDocx distribution file and unzip or untar the archive to your local file system. This sample application is contained in the <em>/samples/mail-merge/convert-batch/</em> directory. If you are using phpLiveDocx for the first time, please review the <a href="http://www.phplivedocx.org/articles/getting-started-with-phplivedocx/">Getting Started Guide</a>.</p>
<p>Copy the files you want to convert into the directory <em>queue</em>. For your convenience, there is already a number of demonstration files in this directory.</p>
<p>Run the <em>run-job.php</em> script with the file format into which you wish to convert your documents. For example:</p>

<div class="wp_syntax"><div class="code"><pre class="bash">./run-job.php --output-format pdf</pre></div></div>

<p>And sit back! phpLiveDocx will convert your documents.</p>
<p>The converted documents (i.e. the PDF versions in the above example) will be placed in the directory <em>output</em>.</p>
<p>The original document will be moved to the directory <em>queue_done</em>.</p>
<p>To get a list of supported output file formats from the command line, simply call <em>run-job.php</em> with no parameters:</p>

<div class="wp_syntax"><div class="code"><pre class="bash">./run-job.php</pre></div></div>

<h2>Automation with cron</h2>
<p>If you are running Linux on your server, you can call the <em>run-job.php</em> script every <em>n</em> minutes to fully automate the task of converting documents.</p>
<p>If you set it up like this, all you have to do is copy the files you want to convert into the <em>queue</em> directory and wait for a maximum of <em>n</em> minutes.</p>
<p>Once the next <a href="http://en.wikipedia.org/wiki/Cron">cron job</a> has been called, the documents will be converted into the desired format in the <em>output</em> directory.</p>
<p>To do this, fire up your <a href="http://en.wikipedia.org/wiki/Cron">crontab</a> editor:</p>

<div class="wp_syntax"><div class="code"><pre class="bash">crontab -e</pre></div></div>

<p>And add the following line to call <em>run-job.php</em> every 5 minutes:</p>

<div class="wp_syntax"><div class="code"><pre class="bash">*/<span style="color: #cc66cc;">5</span> * * * * <span style="color: #000066;">cd</span> <span style="color: #66cc66;">&#91;</span>PATH<span style="color: #66cc66;">&#93;</span>/phplivedocx/samples/mail-merge/convert-batch &amp;&amp; ./run-job.php --output-format pdf | mail -a <span style="color: #ff0000;">&quot;From: [FROM_EMAIL]&quot;</span> -s <span style="color: #ff0000;">&quot;phpLiveDocx Batch Converter&quot;</span> <span style="color: #66cc66;">&#91;</span>TO_EMAIL<span style="color: #66cc66;">&#93;</span></pre></div></div>

<p>Replacing the placeholders (strings between [ and ]) with&#8230;</p>
<ol>
<li><em>[PATH]</em> with the path to the phpLiveDocx sample application.</li>
<li><em>[FROM_EMAIL]</em> with the e-mail FROM which the cron job confirmation should be sent.</li>
<li><em>[TO_EMAIL]</em> with the e-mail TO which the cron job confirmation should be sent.</li>
</ol>
<p>cron will then execute <em>run-job.php</em> every five minutes and in addition sent you an e-mail report of the batch convert job to the specified e-mail address.</p>
<p>The final step to allow the situation, as shown in the above screenshot, is to share the three directories <em>queue</em>, <em>queue_done</em> and <em>output</em> with Windows clients. This can be done via <a href="http://www.samba.org/">Samba</a> or any other network file system supported by Windows and/or Mac. Once the shares are in place, shortcuts to the appropriate network directories can be added to the desktop (illustrated in the right half of the screenshot).</p>
<h2>Need help?</h2>
<p>If you need help, please post your questions and/or comments below or in the <a href="http://www.phplivedocx.org/support/">support forum</a> and I will assist as much as I can.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.phplivedocx.org/2009/05/15/batch-converter-sample-application/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

