Template-Based Document Generation
by Jonathan Maron
Generating well-formatted, print-ready PDF documents with PHP is a notoriously difficult task. Traditionally, there are two main approaches: "The HTML-to-PDF Approach" and "The Programmatic Approach". Given sufficient time and patience, both get the job done, but still leave a lot to be desired. This article introduces an entirely new third approach: It relies on templates being created in a WYSIWYG environment, such as Microsoft® Word, and then being populated with data from PHP. The resulting document can be saved not only to PDF, but also DOCX, DOC and RTF. This cross-platform approach will be implemented using Zend Framework.