php[architect] logo

Want to check out an issue? Sign up to receive a special offer.

PHPDOCX: generating Word documents from PHP

Posted by on July 21, 2010

PHPDOCX is a PHP library that allows its client code to generate Microsoft Word documents in the .docx format from PHP scripts. PHP is increasingly being used for disparate goals and has to deal with data that comes from strange sources and has to be produced in stranger formats. An off-the-shelf solution for the creation of Word documents from an arbitrary source — being it a database, Excel or a csv file — is indeed a good tool to keep at hand.

Starting with the 1.5 version, which has been released on July 12th, PHPDOCX is now compatible with PHP 5.3. The adoption of PHP 5.3 from operating systems is growing and it will at last replace the previous versions of PHP also in the servers of hosting providers.

Features

PHPDOCX provides some standard features that you would commonly use when generating a document dynamically: managing text, list, tables, images and graphic elements are all basic operations of document editing.

There are more useful features included in the library, which come handy when dealing with long documents. For instance, insertion of headers, footers, page numbering, and table of contents are all supported.

A final note on the feature list is the possibility of outputting PDF and HTML from a given Word document. The library is intended for generation of reports and being able to switch the output format at will is a great point.

Technicalities

PHPDOCX has no requirements for a functional version of MS Word, except for generating legacy versions of the documents (.doc format for Word 2004 or before).

The library does requires the zip and xsl PHP extension to work, but they are probably already installed on your server of choice, or available at will. Apart from that, a generic installation of PHP and Apache will suffice.

Licenses

Like many libraries for web development, PHPDOCX comes with more than one license.

The first possibility is to use the library with an LGPL license, which covers the free version. It has somewhat limited features in comparison to the Pro one, but it includes no watermarks in the produced documents nor it has time limits.

The Pro version has greater capabilities, like the insertion of graphs and MathML constructs for scientifical documents. It also provides technical support, which may be the most compelling point for its adoption.

In conclusion, PHPDOCX is a valid tool to manage production of documents in one of the most diffused formats of the world. It also manages PDF and HTML, which guarantee interoperability with any end user’s machine.


Marco is the keeper of keys and Chief Garbage Collector at Blue Parabola. He can be found on Twitter as @mtabini.
Tags: , , , ,
 

Responses and Pingbacks

This is exactly the type of thing we have been looking for. Clients are wanting documents generated straight away

Great work man! congrets…

[…] el blog de php|architect tienen un nuevo articulo acerca de una herramienta que nos ayudara a crear documentos de Word directamente desde nuestras […]

Thank you a lot! 🙂

Just a note: PHPExcel is also very useful for Spreadsheets.

yeah that is a great acheivement, thumbs up

e-Data Pro is the leading Document Scanning and Indexing Service provider in India. We provide Best Practice Outsourcing Services for Document Scanning, enabling your organization to successfully unlock the true value of the information contained in its files, resulting in increased productivity, performance and profits. We are recognized experts in providing document scanning services to support large scale, Mission Critical conversion services for projects that require quick turnarounds and high quality deliverables. Utilizing our advanced technologies and processes, we can provide your organization with the highest image quality and coded data available in the industry today, enabling quick search and accurate retrieval of each secure file. We achieve this by tailoring our services to meet the unique requirements of each project.
Document scanning is the process of scanning paper documents, converting them to digital images that are then stored on CD, DVD, or other magnetic storage. Document scanning service can greatly reduce storage space that is required for keeping paper copies. The productivity of staff will increase using document scanning service because documents will be more easily located and accessed. Document scanningservice will reduce the headache of photocopy, fax, and mail transport. Document scanning service will give your business a time and money advantage over competitors who do not take up such services.

http://www.e-datapro.net/document_scanning.htm

Works very nice. Using the free version. One problem though, the language of the generated Word document is set to Spanish and all my text is in English, so the spell checker is saying pretty much every word is spelled wrong.

The problem with the language has already been corrected in PHPDocX v 2.1
(http://www.phpdocx.com).

Best regards,

Eduardo

The 3.0 version of the library has just been released with multiple enhancements in functionality and performance.

Does the latest version of livedocx support nested tables yet?

Leave a comment

Use the form below to leave a comment: