Brief introduction to LiveDocx in PHP
Summary
Zend_Service_LiveDocx allows developers to generate documents by combining structured data from PHP with a template, created in a word processor. The resulting document can be saved as a PDF, DOCX, DOC or RTF file. The concept is the same as with mail-merge.
Work flow overview
- Load template in Zend_Service_LiveDocx.
- Assign data to text fields in template.
- Generate document.
- Save as a PDF, DOCX, DOC or RTF file.
Work flow as PHP
This template is populated with the following data to generate this document.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | $mailMerge = new Zend_Service_LiveDocx_MailMerge(); $mailMerge->setUsername('myUsername') ->setPassword('myPassword'); $mailMerge->setLocalTemplate('template.docx'); $mailMerge->assign('software', 'Magic Graphical Compression Suite v1.9') ->assign('licensee', 'Henry Döner-Meyer') ->assign('company', 'Co-Operation') ->assign('date', 'January 11, 2010') ->assign('time', 'January 11, 2010') ->assign('city', 'Berlin') ->assign('country', 'Germany'); $mailMerge->createDocument(); $document = $mailMerge->retrieveDocument('pdf'); file_put_contents('document.pdf', $document); |
Try for yourself
Want to try this out?
Take a look at the getting started guide for details or contact the author.