Is it possible to style the numbers or bullets in a list style? e.g. if I want to make the bullet itself a square that is green, but not alter the text in the list.
Is it possible to style the numbers or bullets in a list style? e.g. if I want to make the bullet itself a square that is green, but not alter the text in the list.
Hello,
Do you need to create a new list style or customize an existing style?
In the first case you can use createListStyle to set custom colors and other styles. For example:
// custom Bullets
$latinListOptions = array();
$latinListOptions[0]['type'] = 'bullet';
$latinListOptions[0]['color'] = 'FF0000';
$latinListOptions[1]['type'] = 'bullet';
$latinListOptions[1]['color'] = '00FF00';
$latinListOptions[2]['type'] = 'bullet';
$latinListOptions[2]['color'] = '0000FF';
// create the list style with name: myList
$docx->createListStyle('myList', $latinListOptions);
// list items
$myList = array('item 1', array('subitem 1.1', 'subitem 1.2', array('subitem 1.2.1')), 'item 2', 'item 3');
// insert custom list into the Word document
$docx->addList($myList, 'myList');
In the second case you can use customizeWordContent (available in Premium licenses) to change styles on-the-fly, for example to set a new custom list style for specific contents or customize an existing numbering. In this case you need to set the numbering ID to be changed or any other attribute such as the level. For example, to change the color, format, start and levelText settings of the first level of all numbering styles (DocxCustomizer/sample_15.php includes a similar sample):
$referenceNode = array(
'target' => 'numbering',
'type' => 'style',
'attributes' => array('w:ilvl' => '0'),
);
$docx->customizeWordContent($referenceNode,
array(
'color' => 'FF00FF',
)
);
$referenceNode = array(
'target' => 'numbering',
'type' => 'numbering',
'attributes' => array('w:ilvl' => '0'),
);
$docx->customizeWordContent($referenceNode,
array(
'levelText' => '%1.',
'numberingFormat' => 'decimal',
'numberingStart' => 2,
)
);
If you need a more specific sample, please send a DOCX sample to contact[at]phpdocx.com and we'll generate a sample script.
Regards.