Forum


Replies: 1   Views: 683
How do i change style inside the list?
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 martinsimmermann  · 09-09-2022 - 07:49

How do I change text style inside list:

    $Txt1 = array(
        // I want this sentence to be bold:
        'Hello world',
        // And this to remain not bold:
        array('Hello World',)
    );

    // Numeratsiooni lisamine dokumenti
    $docx->addList($Txt1, 'numeration');

 

Posted by admin  · 09-09-2022 - 08:25

Hello,

You need to use WordFragments (https://www.phpdocx.com/documentation/practical/wordfragments-and-wordml). For example:

$textContent = new WordFragment($docx);
$textContent->addText('Hello world', array('bold' => true));

$list = array(
    $textContent,
    'Other text',
);

$docx->addList($list);

You can find more samples using WordFragments in the examples folder included in the package.

Regards.