Replies: 3   Views: 438
Table not rendering correctly from embedhtml table
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 pwctechnicalsecurity  · 20-10-2019 - 14:30

Edited by pwctechnicalsecurity · 20-10-2019 - 15:07


I am trying to render a table from something like:

<table class='capabilities'>

Defined the WordStyles in my embedHTML options array (

".capabilities" => "Capabilities"

) and everything seems to be OK. Except for some very small details in the spacing of text within the table. If the text is aligned directly to the right, there is 0 "margin"; it renders directly against the left side of the cell. However, if I select the table and apply the exact same style through Table Design -> Table Styles then the text seem to have some more "margin". If I try to alter the Table Style in the base template and add identation of 0,1 or 0,2 cm, it seems to render better, but if I create a new table in the resulting Word document itself and select that Table style the spacing seems "double".

I tried to debug all this by creating a Word file through PHPDocX, copy the faulty file in the same Word document and then apply the same table style to the second table. Subsequently, I renamed the docx and opened the documents.xml file to compare the exact sections to see what is the difference; this seems to mainly reside in the textId. Also refer to the following diff:

The paragraphs <w:p> in the table were I clicked on the Table Style in Word, seems to have a unique w14:textId (instead of a default "77777777"). Something seems to be applied when doing it through Word, that is not applied when going through the PHPDocX module. Already tried to play around with paragraphs: embed the whole table in <p> tags and embed the text in <td> tag, like <td><p></p></td>. Both to no avail.

Moreover, there seems to be a snippet that is included in the direct PhpDocX output, but which is not included in the Word render:

<w:left w:w="0" w:type="dxa"/>
<w:right w:w="0" w:type="dxa"/>

Any ideas on how to fix this? Your help is much appreciated!

Posted by pwctechnicalsecurity  · 20-10-2019 - 16:04

Seems like I have found the problem as the difference is that the Left and Right default cell margin is not set to 0,19 cm through the embedHTML function. Any tips / tricks on how to set this properly?

Posted by admin  · 20-10-2019 - 16:56


Attributes such as w14:textId or w14:paraId aren't used to set styles but for extended comments and others.

w:left and w:right tags in w:tblCellMar tag are set using padding-left and padding-right styles, you can use them to set both values instead of the default 0. As you are using a Premium license you can also use DOCXCustomizer to customize both values after the HTML has been transformed (


Posted by pwctechnicalsecurity  · 21-10-2019 - 20:27

Works! Thanks!