Forum


Replies: 1   Views: 1114
Using replacevariablebyhtml() changes the default styling of template variable after substitution.
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 ZooEasy Online Support  · 13-04-2020 - 12:29

When I try to use replaceVariableByHTML() function for substituting the value of the template variable in a docx document, the default styling of template variable is lost in the resultant document when downloaded. The size of the font changes to 12 pt, with Arial font applied by default. On the contrary when I use the function replaceVariableByText() instead, this issue does not occurs.

I am using the PHPDocx version 7.0

Please guide.

Posted by admin  · 13-04-2020 - 13:39

Hello,

replaceVariableByHTML doesn't keep the styles used by the placeholder, you need to set them in the imported HTML, otherwise, default imported styles are applied.

When doing a block type replacement, as replaceVariableByHTML does, styles from the placeholder aren't kept. Doing an inline type replacement, as replaceVariableByText does, almost all styles from the placeholder are set. On the documentation pages, you can read this information explained.

If you want to preserve the placeholder styles (pPr and rPr) when replacing a placeholder by HTML using replaceVariableByHTML, you need to use a Premium license. As you are using an Advanced license, we recommend you to upgrade your license to Premium and the dev team we'll send you the steps to accomplish this task.

Regards.