Forum


Replies: 3   Views: 1852
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

Hi,

I am trying to render a table from something like:

<table class='capabilities'>
  <tr>
    <td>xy</td>
    <td>za</td>
  </tr>
</table>

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:

https://www.diffchecker.com/QTUeDDC9

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:tblCellMar>
<w:left w:w="0" w:type="dxa"/>
<w:right w:w="0" w:type="dxa"/>
</w:tblCellMar>

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