Today we launch a new version of PHPdocX with new features. We been very busy last weeks coding, testing and updating the library with some new characteristics and a major feature: now it’s possible create templates with placeholders to generate dynamic .docx documents.
Also, we made some aditions to PHPdocX 1.6: now you can use styled text into a cell on a table, text indenting with spaces (or tabs) and control over cell’s height on tables.
There are two new functions for tables and templates: fAddTable and fAddTemplate.
All this new stuff are only available on the PRO version, and with the download, you have a new set of examples that will help you with the all set of new features: check Table.php, Text_tabs_spaces.php and Template.php.
In fact, this new feature open a door to Mail Merge: Mail merge is a software function describing the production of multiple (and potentially large numbers of) documents from a single template form and a structured data source.This helps to create personalized letters and pre-addressed envelopes or mailing labels for mass mailings from a word processing document which contains fixed text, which will be the same in each output document, and variables, which act as placeholders that are replaced by text from the data source.
The new feature with text templates do this in a very easy and clever way opening a new use for PHPdocX never seen before.
If you are using addhtml() for generating a .docx file, you must remember that PHPdocX is very smart, but Word don’t understand things like “medium” or “big”.
Code like this:
<p>This will insert the name in the document: <strong><span style="font-size: medium;">The Name</span></strong></p>
Will be no rendered. You must specify the font size as pixels on font-size’s tag like this:
<p>This will insert the name in the document: <strong><span style=" font-size: 12px;”>The Name</span></strong></p>
If you install PHPdocX in Mac OS X Server (10.4 or above) you could easily convert the .docx documents created using this command in a Shell Window:
textutil -convert doc /route/to/document_sample.docx
Texutil can convert also from doc to .docx (and html, rtf, odt and more formats)
textutil -convert docx /route/to/document_sample.doc
On Snow Leopard there is no man page for Texutil, so, you need to go to Apple, where there is more info about Textutil and how to use it.
You could batch the conversion of multiple files using a command; this is an example to convert files from .docx to .doc:
find . -name *.docx -exec textutil -convert doc '{}' \;
On Linux, you need to install the texutil package. Texutils can’t convert all elements from a .docx to a .doc file: you will loose images and graphics (piecharts and so), but tables (without colors) and formated text will be preserved.
But this not the only way to convert from .docx to .doc: there are more tricks … just wait for more info and new posts.
If you want to install you license of PHPDocX in your server, remember that the domain must be the same that you use when register the software: you can’t use a subdomain because the verification included with you copy will search only for the original domain you registered. You need to buy one copy for each subdomain if you want to use PHPDocX on them. Read more