Forum


Replies: 1   Views: 415
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

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.