Replies: 1   Views: 1762
Replacevariablebytext seems to fail randomly on only one or two fields
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 admin  · 09-08-2019 - 07:23


There's no known bug using template methods such as replaceVariableByText and we have hundreds of unit tests of these features.

MS Word can break strings adding extra tags, but since phpdocx 3 (launched years ago), phpdocx handle them perfectly. On (Replacement of variables with preprocessed documents section) you can read the full description of how this MS Word behaviour works.

Please note that phpdocx cleans that placeholders automatically unless you load the template setting the preprocessed as true:

$docx = new CreateDocxFromTemplate('template.docx', array('preprocessed' => true));

If you set this option as true (default is false) to get a faster performance, then phpdocx doesn't repair the placeholders and broken placeholders aren't remove correctly. On the previous page you can read all information.

As your license has an active LUS, have you tested the same DOCX and script using phpdocx 9? If you send to contact[at] a sample of the DOCX that contains some placeholder not replaced correctly will check it.