Forum


Replies: 1   Views: 1753
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 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 with HTML using replaceVariableByHTML, you need to use the stylesReplacementType option available in Premium licenses.

Regards.