Forum


Replies: 1   Views: 1262
Createfromtemplate, replacevariablebyhtml : apply template style
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  · 10-01-2021 - 14:33

Hello,

When HTML is transformed to DOCX, default styles are applied that you can change using custom styles (CSS styles, MS Word styles).

To preserve the styles of a placeholder when replacing HTML in a template you need to use the stylesReplacementType option (https://www.phpdocx.com/api-documentation/templates/replace-variable-html-Word-document), but it's only available in HTML Extended for Premium licenses, the trial package doesn't include it. Using a not Premium license you need to set the styles to be applied in the HTML you are adding to the template. You can read this same information on https://www.phpdocx.com/documentation/introduction/html-extended-to-word-PHP (Replace placeholders keeping styles section).

Regards.