forked from PHPOffice/PHPWord
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSample_20_BGColor.php
More file actions
23 lines (20 loc) · 831 Bytes
/
Sample_20_BGColor.php
File metadata and controls
23 lines (20 loc) · 831 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php
include_once 'Sample_Header.php';
// New Word document
echo date('H:i:s'), ' Create new PhpWord object', EOL;
$phpWord = new \PhpOffice\PhpWord\PhpWord();
$section = $phpWord->addSection();
$section->addText(
htmlspecialchars('This is some text highlighted using fgColor (limited to 15 colors) ', ENT_COMPAT, 'UTF-8'),
array('fgColor' => \PhpOffice\PhpWord\Style\Font::FGCOLOR_YELLOW)
);
$section->addText(
htmlspecialchars('This one uses bgColor and is using hex value (0xfbbb10)', ENT_COMPAT, 'UTF-8'),
array('bgColor' => 'fbbb10')
);
$section->addText(htmlspecialchars('Compatible with font colors', ENT_COMPAT, 'UTF-8'), array('color' => '0000ff', 'bgColor' => 'fbbb10'));
// Save file
echo write($phpWord, basename(__FILE__, '.php'), $writers);
if (!CLI) {
include_once 'Sample_Footer.php';
}