Replies: 1   Views: 2433
Replacevariablebyexternalfile() and styles
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 afantini  · 26-04-2018 - 13:52

Using replaceVariableByExternalFile() I find that the text loses all the formatting styles used in the external file, being all formatted with the "normal" style: this, of course, despite the same styles are also present in the template.

Am I making a mistake?How can this be remedied?

Thank you.

Posted by admin  · 26-04-2018 - 14:23


That method uses altChunk tags, that are only supported by MS Word 2007 or newer on Windows. This way of adding external files is handled by MS Word, although you can set matchSource as true ( some styles won't keep.

If you are adding HTML, we recommend you to use native methods that transform HTML to Word:

If you need to add DOCX documents, you can use the mergeDocx method to keep content and styles: