Forum


Replies: 3   Views: 1964
Unable to set default font style using replacevariablebyhtml() function.
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-05-2020 - 15:56

Hello,

UPDATE: phpdocx 10 Premium and newer releases include the stylesReplacementType option in replaceVariableByHTML to use placeholder styles (or mix HTML and placeholder styles if needed).

replaceVariableByHTML adds default styles to the imported contents, existing placeholder styles are replaced by the new ones. Using other replacement methods with inline replacements keep the styles from the placeholders, such as replaceVariableByText.

You need to apply the styles to be used to replaceVariableByHTML through CSS when transforming the HTML. You can get styles applied to contents using getWordStyles: https://www.phpdocx.com/api-documentation/docx-path/get-styles-word-contents-in-docx

You can also use custom styles when generating the DOCX from HTML: https://www.phpdocx.com/documentation/introduction/html-to-word-PHP (Using native Word formatting with HTML section).

If you send a DOCX sample to contact[at]phpdocx.com we'll generate a custom script to illustrate how to accomplish this task.

Regards.