Forum


Replies: 2   Views: 1784
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 admin  · 18-05-2020 - 10:51

Hello,

'Heading 1' is not an allowed type (https://www.phpdocx.com/api-documentation/docxcustomizer/customize-docx-Word-documents-PHP):

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'),
);

$docx->customizeWordContent($referenceNode, 
    array(
        '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.

Regards.