Replies: 1   Views: 108
Replacevariablebytext seems to fail randomly on only one or two fields

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.