Hello,
The replaceVariableByText method doesn't transform HTML, this method replaces a placeholder by a new text (plaing strings).
If you want to replace a placeholder with HTML you need to use replaceVariableByHTML. But please note that this method supports many HTML tags and CSS styles but not all, for example HTML canvas tag isn't supported when transforming HTML. We recommend you to read the following pages that detail all suported contents and styles when transforming HTML:
- HTML to Word: https://www.phpdocx.com/documentation/introduction/html-to-word-PHP
- HTML Extended (only available in Premium licenses): https://www.phpdocx.com/documentation/introduction/html-extended-to-word-PHP
- HTMLAPI documentation: https://www.phpdocx.com/documentation/htmlapi-documentation
- Word to HTML: https://www.phpdocx.com/documentation/introduction/word-to-html-PHP . On this page you can find the supported contents and styles when transforming DOCX to HTML, but please note there's no option to generate a button to submit a form, so it should be added externally (for example using DOM and loadHTML from PHP to edit the HTML output generated by phpdocx).
Instead of a canvas you could add an input field or other MS Word content type to generate a box when transforming HTML. Also please note that some HTML tags and CSS styles don't have a MS Word equivalent.
Regards.