Tobias Bernd Bauer
Tobias Bernd Bauer

Reputation: 51

Create TextBox without a border in PHPWord

I'm trying to create a TextBox without a border in PHPWord, but setting borderColor or borderSize to 0 or null has no effect and I always get at least a black border around the text box.

$phpWord = new \PhpOffice\PhpWord\PhpWord();
$textbox = $section->addTextBox(
    array(
        'alignment'   => \PhpOffice\PhpWord\SimpleType\Jc::END,
        'width'       => 200,
        'height'      => 40,
        'borderColor' => null,
        'borderSize'  => 0,
    )
);
$textbox->addText('dummy-text ...', null, array('alignment' => \PhpOffice\PhpWord\SimpleType\Jc::END));
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord);
$objWriter->save('dummy.docx');

Upvotes: 1

Views: 2761

Answers (2)

Barcioch
Barcioch

Reputation: 1

If anyone is still looking for an answer in PHPWord 0.17 following solution works:

'borderColor' => 'none'

Upvotes: 0

ejuhjav
ejuhjav

Reputation: 2710

To create a borderbox without border you can use (git issue: no outline textbox):

'borderSize' => 'none'

Tested and working with PhpWord 0.13.0 & opening the generated document with MsWord (libreoffice didn't seem to recognize this setting)

Upvotes: 1

Related Questions