Sample 20 BGColor

19:30:12 Create new PhpWord object
19:30:12 Write to Word2007 format
19:30:12 Write to ODText format
19:30:12 Write to RTF format
19:30:12 Write to HTML format
19:30:12 Write to PDF format ... NOT DONE!
19:30:12 Write to EPub3 format
19:30:12 Done writing file(s)
19:30:12 Peak memory usage: 2 MB

 

Results: docx odt rtf html epub


<?php


include_once 'Sample_Header.php';

// New Word document
echo date('H:i:s'), ' Create new PhpWord object', EOL;
$phpWord = new PhpOffice\PhpWord\PhpWord();

// New section
$section = $phpWord->addSection();

$section->addText(
    
'This is some text highlighted using fgColor (limited to 15 colors)',
    [
'fgColor' => PhpOffice\PhpWord\Style\Font::FGCOLOR_YELLOW]
);
$section->addText('This one uses bgColor and is using hex value (0xfbbb10)', ['bgColor' => 'fbbb10']);
$section->addText('Compatible with font colors', ['color' => '0000ff', 'bgColor' => 'fbbb10']);

// Save file
echo write($phpWord, basename(__FILE__, '.php'), $writers);
if (!
CLI) {
    include_once 
'Sample_Footer.php';
}