Forum


Replies: 1   Views: 265
Align textbox with outer text
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  · 28-06-2024 - 21:43

Hello,

Textboxes are added using absolute positions as default. To add a textbox as "in line with text" you can set an empty value in the align option. Please note that you can also add a textbox in a WordFragment to apply extra styles (such as paragraph styles).

For example:

$docx = new CreateDocx();

$docx->addTextBox('myval', array('align' => ''));
$docx->addText('my label');
$docx->addBreak();

$textBoxFragment = new WordFragment($docx);
$textBoxFragment->addTextBox('myval', array('align' => ''));
$docx->addText([$textBoxFragment], array('textAlign' => 'center'));
$docx->addText('my label');

$docx->createDocx('output');

Regards.