Forum


Replies: 1   Views: 3565
Template variable substitution using other documents
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by Philippe GAUTHIER  · 07-11-2015 - 10:06

Hello,

We use PhpDocx in a document generation engine, which substitutes multiple variables from user defined templates. The sources are loaded from a domain model, and the engine handles all that using two kind of substitution : simple text and html (written by users in web editors).

We are studying the possibility of integrating other docx documents inside a variable, in the same fashion as we do for html. As PhpDocx implements WordML substitution (replaceVariableByWordML), I think this should be quite straightforward, but this scenario is not documented (or maybe I missed it).

So the questions :

Is it possible to obtain the WordML code of the body of an existing Word document (don't care about header, footer and other parts) ? Is this code directly usable in WordML fragment or need some treatment (extraction, replacement) ?

Thanks in advance.

 

 

Posted by admin  · 08-11-2015 - 12:11

Hello,

The current version of phpdocx doesn't include any method to get the WordML of existing contents in DOCX; it will be added in a next version of the library. It's a complex task due to interal dependencies and references .

Maybe you could use this method:

http://www.phpdocx.com/api-documentation/templates/replace-variable-external-file-Word-document

that allows to replace a placeholder by a DOCX, HTML, RTF or MHT. It only works for MS Word 2007 and newer.

Regards.