Forum


Replies: 4   Views: 4303
Text align html to docx
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  · 23-05-2018 - 17:03

Hello,

The problem is that you are doing an inline replacement. Using this kind of replacement, block elements are removed and only the variable is replaced.

We recommend you to read the information available on:

https://www.phpdocx.com/documentation/introduction/html-to-word-PHP (Inserting HTML into Word templates section)

https://www.phpdocx.com/api-documentation/templates/replace-variable-html-Word-document (Parameters section)

MS Word allows setting the alignment to paragraphs, tables, images... You need to use a block type replacement to set a new alignment:

$docx->replaceVariableByHTML($section, 'block', $html);

Regards.