Yes, you can replace placeholders by a new text that includes styles. Even by other contents such as images, tables, charts... or multiple contents.
You need to use WordFragments and the replaceVariableByWordFragment method. On the previous page and the package you can find samples that detail how to use this method. Please also check the following page availabler in the Practical guide about working with WordFragments : https://www.phpdocx.com/documentation/practical/wordfragments-and-wordml
The following sample replaces a text placeholder by a new text content with styles (bold, color and fontSize):
$docx = new CreateDocxFromTemplate('template.docx'); $textFragment = new WordFragment($docx, 'document'); $textStyles = array( 'bold' => true, 'color' => 'B70000', 'fontSize' => 24, ); $textFragment->addText('new text', $textStyles); $docx->replaceVariableByWordFragment(array('WORDFRAGMENT' => $textFragment), array('type' => 'inline')); $docx->createDocx('output');
WordFragment is a very powerful class included in phpdocx to add contents.
HTML could also be used to replace a placeholder using replaceVariableByHTML, but please note that transforming HTML adds default styles.
Please note the license you are using includes support tickets. If needed, you can open a ticket on MY PHPDOCX page after log in with the user that purchased the license, attaching a DOCX template you are using and we'll generate a custom sample using it.