Forum


Replies: 7   Views: 5994
Horizontal aligment in table cell?
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  · 03-11-2015 - 09:17

Hello,

This is a simple example to add centered text:

<?php

require_once '../../classes/CreateDocx.inc';

$docx = new CreateDocx();

$textFragment = new WordFragment($docx);
$text = array();
$text[] =
    array(
        'text' => 'Centered text',
        'underline' => 'single'
    );
$paragraphOptions = array(
    'textAlign' => 'center',
);
$textFragment->addText($text, $paragraphOptions);

$valuesTable = array(
    array(
        $textFragment,
    ),
    array(
        'Other text',
    ),
    array(
        'Other text',
    ),
);

$docx->addTable($valuesTable);

$docx->createDocx('output');

Regards.