2
votes

I'm trying to set the background color of a text both either to a color, or to 100% transparent (whatever is easiest) but I'm struggling to achieve either.

I've tried "bgColor" as per some other elements but no luck :(

 $textbox = $section->addTextBox(
        array(
            'marginTop' => -100,
            'marginLeft' => -100,
            'posHorizontal' => 'absolute',
            'posVertical' => 'absolute',
            'align' => 'left',
            'positioning' => 'relative',
            'width'       => 200,
            'height'      => 40,
            'borderColor' => '#eeeeee',
            'borderSize'  => 0,
            'bgColor' => 'black',
        )
    );
3
FYI 'bgcolor' is not a correct property... use 'background-color' for instead of bgcolor...saravanan
No luck with that unfortunately, although no other properties are hyphenated?AdrianGW
Any idea did you find a solution ? Another question did Text box support border radius/ round ?famas23

3 Answers

2
votes

Try this

'fillColor' => 'black'

Or

'fillColor' => '#BFBFBF'

you can find all properties in PhpWord\Style\TextBox.php

0
votes

Does anyone how to do this, also have this issue. The documentation has not been updated in years. AddTextBox doesnt exist on docs...

'fill'      => array('color' => '#990000'),
'bgColor'      => '#990000',
'backgroundColor'      => '#990000'

None of the above work.

0
votes

For anyone looking for this answer here it goes:

There's no answer, textbox don't support any kind of background yet and looks like it wont. As this issue suggests you can achieve the same results in terms of design with a table with a single cell.