Replies: 1   Views: 2481
Add border, margin and padding for addformelement textbox field
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 peterdan  · 31-05-2017 - 01:48


Im trying to add border and padding to a textfield element through addFormElement but im having hard time getting it to work.

Can you give me example to give it a border and padding to the form?

this is my code  as of now..but its not giving it a border.

$docx = new CreateDocx();

$text = array();
$text[] = array('text' => 'x =');

$frag = new WordFragment($docx);

$textFieldOptions = array(
    $frag->addFormElement('textfield', $textFieldOptions);
    $text[] = $frag;
    $text[] = array('text' => 'two');
    $docx->addText($text, $options);

btw, i have the premium version in case you want to know.

Posted by admin  · 31-05-2017 - 07:39


That styles are applied to paragraphs (as you can read on its page API: 'This is an array including all general paragraph wide options.').

For example this code adds a border to the paragraph of the textfield:

$textFieldOptions = array(
        'defaultValue' => 'This is a test',
$docx->addFormElement('textfield', $textFieldOptions);

Paragraph styles are ignored for inline elements. On the addText method API page you can read the supported rPr styles: underline, bold, color, italic, linebreak, spacing, strikeThrough...

About indentation, MS Word supports adding left and right indentations for paragraphs, but not for characters. phpdocx supports indentations and spacings for paragraphs as well. As MS Word allows, you can use tabs or add spaces to separate text contents in the same paragraph.

The next version of phpdocx will add rStyles ID support. We have also added a task to add rPr borders per your request.