Forum


Replies: 1   Views: 1754
Placeholders with html - need to keep basic word styling.
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 katethomas  · 11-02-2020 - 02:16

When using placeholders such as $NOTES$ we can insert text into a user created Template without issue.  The docx created will use the styling applied to $NOTES$ from within the template using: replaceVariableByText

If $NOTE$ is stored as html, then we can recreate the styling in the created docx using: replaceVariableByHTML

What we can not seem to do, it to create a docx using html, but also keep the styling that the customer has applied for $NOTES$ on their template - it always reverts back to default font and size when using replaceVariableByHTML - Is it possible to do ?

Posted by admin  · 11-02-2020 - 13:22

Hello,

That feature, keep existing styles when replacing a placeholder by HTML, will be available in phpdocx 10 as HTML Extended option. Please note that HTML Extended is only available in Premium licenses.

As phpdocx 10 hasn't been released yet, it only can be used by users with a Premium license and LUS active; if you upgrade your license and send an e-mail to contact[at]phpdocx.com, the dev team will send you the new classes and samples about how to use it.

Using the current version of replaceVariableByHTML there's no other option than set the font-family and font-size to be used. Using getWordStyles, available since the release of phpdocx 9 in Advanced and Premium licenses,you can get styles from an existing content so they can be added dynamically to the HTML to be added.

Regards.