Forum


Replies: 1   Views: 1143
Replacevariablebyhtml - keep font size and font face
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-06-2021 - 06:45

Hello,

HTML to DOCX methods set a default font size and font family to handle all CSS styles and properties. Until the launch of phpdocx 10, when you replaced a placeholder using replaceVariableByHTML, the new contents applied font size and font family styles from the HTML/CSS (default styles when not set) overwriting the placeholder styles; so to apply the exact placeholder styles they needed to be added manually to the HTML/CSS or caught dynamically using getWordStyles.

Since the release of phpdocx 10, Premium licenses include the stylesReplacementType option in replaceVariableByHTML. This option allows mixing and replacing HTML/CSS and placeholder styles when doing replacements. We recommend you to read the information available about this option on https://www.phpdocx.com/api-documentation/templates/replace-variable-html-Word-document, and also checks the included samples in the package, that illustrates how to use this option.

Regards.