Forum


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

Posted by admin  · 09-08-2019 - 07:23

Hello,

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 https://www.phpdocx.com/documentation/cookbook/improve-performance-with-templates (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]phpdocx.com a sample of the DOCX that contains some placeholder not replaced correctly will check it.

Regards.