Forum


Replies: 7   Views: 3473
Addelement and addtext
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 Skitny  · 02-03-2011 - 06:42

When using addElement to create formatted text to place in a list or table the output is just garbage text.

Can anyone post a working example of using formatted text with addElement, as the provided examples are link and image only.

Posted by admin  · 11-04-2013 - 12:12

Hi,

This is a piece of code of a new example that will be included in phpdocx pro 2.2 that do this feature:

$paramsHeaderTextTable[0] = array(
'text' => 'Text',
'b' => 'single',
'sz' => 14
);

$table[] = array(
$docx->addElement('addText', $paramsHeaderTextTable),
'Value 2',
'Value 3',
);

Regards.

Posted by Skitny  · 11-04-2013 - 12:12

Great!

Eagerly awaiting v2.2

Posted by xkp  · 11-04-2013 - 12:12

following the example you suggest above i have tried this:


$paramsTable = array(
'border' => 'single',
'border_sz' => 10,
'size_col' => 2000
);

$paramsLeftTextTable[0] = array(
'text' => 'Left',
'b' => 'single',
'jc' => 'left',
'sz' => 14,
);

$paramsRightTextTable[0] = array(
'text' => 'Right',
'b' => 'none',
'jc' => 'right',
'i' => 'single',
'sz' => 11,
);

$table[] = array($docx->addElement('addText', $paramsLeftTextTable),$docx->addElement('addText', $paramsRightTextTable));
$docx->addTable($table, $paramsTable);


everything works fine ('b', 'i', 'sz') EXCEPT the 'jc'.

as both the elements of the table have left alignment on my docx.

Any idea the reason why?
Please advice.

I am using docx 2.5 PRO and word 2007.

Thanks in advance.

Posted by admin  · 11-04-2013 - 12:12

Hello,

We'll check that issue.

Regards.

Posted by kshaikh  · 23-09-2013 - 03:04

I am using v3.5 pro and I am having the same issue with the alignment using jc as xkp mentioned in his post. 



admin-phpdocx, please advice.


Posted by jorgelj  · 23-09-2013 - 09:36

Hello,



The addElement method is deprecated so we recommend you to use wordmlfragments to do this. You can check included examples.



Regards.