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) 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.
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.
Supported file formats
The following input file formats are supported:
- DOCX – Office Open XML Format
- DOC – Microsoft Word DOC Format
- RTF – Rich Text File Format
- TXD – TX Text Control Format
The following output file formats are supported:
- DOCX – Office Open XML Format
- DOC – Microsoft Word DOC Format
- HTML – XHTML 1.0 Transitional Format
- RTF – Rich Text File Format
- PDF – Acrobat Portable Document Format
- TXD – TX Text Control Format
- TXT – ANSI Plain Text
Getting started
Download the current phpLiveDocx distribution file and unzip or untar the archive to your local file system. This sample application is contained in the /samples/mail-merge/convert-batch/ directory. If you are using phpLiveDocx for the first time, please review the Getting Started Guide.
Copy the files you want to convert into the directory queue. For your convenience, there is already a number of demonstration files in this directory.
Run the run-job.php script with the file format into which you wish to convert your documents. For example:
./run-job.php --output-format pdf
And sit back! phpLiveDocx will convert your documents.
The converted documents (i.e. the PDF versions in the above example) will be placed in the directory output.
The original document will be moved to the directory queue_done.
To get a list of supported output file formats from the command line, simply call run-job.php with no parameters:
./run-job.php
Automation with cron
If you are running Linux on your server, you can call the run-job.php script every n minutes to fully automate the task of converting documents.
If you set it up like this, all you have to do is copy the files you want to convert into the queue directory and wait for a maximum of n minutes.
Once the next cron job has been called, the documents will be converted into the desired format in the output directory.
To do this, fire up your crontab editor:
crontab -e
And add the following line to call run-job.php every 5 minutes:
*/5 * * * * cd [PATH]/phplivedocx/samples/mail-merge/convert-batch && ./run-job.php --output-format pdf | mail -a "From: [FROM_EMAIL]" -s "phpLiveDocx Batch Converter" [TO_EMAIL]
Replacing the placeholders (strings between [ and ]) with…
- [PATH] with the path to the phpLiveDocx sample application.
- [FROM_EMAIL] with the e-mail FROM which the cron job confirmation should be sent.
- [TO_EMAIL] with the e-mail TO which the cron job confirmation should be sent.
cron will then execute run-job.php every five minutes and in addition sent you an e-mail report of the batch convert job to the specified e-mail address.
The final step to allow the situation, as shown in the above screenshot, is to share the three directories queue, queue_done and output with Windows clients. This can be done via Samba 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).
Need help?
If you need help, please post your questions and/or comments below or in the support forum and I will assist as much as I can.

March 22nd, 2010 at 17:52
the sample project is nowhere to be found…
/samples/mail-merge/convert-batch/ is not there
ZendFramework\demos\Zend\Service\LiveDocx\MailMerge\convert\ is there alright… where can I download the projecT?
March 31st, 2010 at 15:03
Please take a look at this forum thread. It contains the project as a ZIP file that you can download:
http://www.theimagingsourceforums.com/showthread.php?t=323144