Replies: 2   Views: 1454
Customizewordcontent not allowing change
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by dannyguest  · 18-05-2020 - 09:16


I am attempting to use customizeWordContent to change the font colour of the "Heading 1" style of predefined headers within a template. 

Here is my code:

$referenceNode = array(
                'type' => 'Heading 1'

                    'color' => '#000000'

What am I doing wrong? All I want to do is in some situations change the colour. 

Posted by admin  · 18-05-2020 - 10:51


'Heading 1' is not an allowed type (

type  string  * (all), break, image, list, paragraph, run, section, style, table, table-row, table-cell.

Please check the included sample examples/DocxCustomizer/sample_9.php that changes styles from the style target. For example:

$referenceNode = array(
    'target' => 'style',
    'type' => 'style',
    'attributes' => array('w:styleId' => 'myStyle'),

        'bold' => false,
        'italic' => false,
        'backgroundColor' => 'FF0000',
        'caps' => false,
        'lineSpacing' => 240,

Please note the previous sample uses the attribute w:styleId that may not be the same that the style name. Heading1 should be the styleId for Heading 1 . Using parseStyles you can get the styles from an existing DOCX.


Posted by dannyguest  · 19-05-2020 - 07:56

That worked for me thank you for the help as always.