Forum


Replies: 3   Views: 3749
How center html 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 admin  · 20-12-2016 - 07:46

Hello,

This is a sample of how to center a table (you can test it with the file TemplateHTML.docx included in the package):

<?php

require_once 'classes/CreateDocx.inc';

$docx = new CreateDocxFromTemplate('examples/files/TemplateHTML.docx');

$docx->replaceVariableByHTML('CHUNK_1', 'block', '<table align="center"><tr><td>AAA</td><td>AAA</td></tr><tr><td>BBB</td><td>BBB</td></tr><tr><td>CCC</td><td>CCC</td></tr></table>', array('parseDivsAsPs' => true));

$docx->createDocx('output');

It's tested and working as expected.

Regards.