Forum


Replies: 1   Views: 1509
Html is not being rendered in list (addlist)
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 anilkumar  · 03-09-2020 - 17:37

Hello, 

I'm using wordFragment with addText and embedHTML and then adding that WF into the list item array, all the styles are applied like bold, italic and font size but unordered and ordered list i.e. <ul><li>Test Item 1</li><li>Test Item 2</li></ul> is not applied. it is showing me only text like "Test Item 1Test Item 2"

Following is the code snap:

 $TestData = new WordFragment($this->docx);
 $TestData->addText('Test Code', ['bold' => true, 'fontSize' => 12]);
 $TestData->embedHTML('<ul><li>Test Item 1</li><li>Test Item 2</li></ul>', ['stri           ctWordStyles' => true]);
 $items = [
        $TestData,
    ];
$docx->addList($items, 1, ['fontSize' => 10]);

I have advanced package of PHPDocx.

Note: this code is inside the Foreach loop, so it can run multiple times and this $TestData WF can be inside nestedList.

Thanks.

Posted by admin  · 03-09-2020 - 18:12

Hello,

WordFragments added in addList and some other block contents that only allows inline elements, remove block contents from the WordFragment (https://www.phpdocx.com/documentation/practical/wordfragments-and-wordml), so only inline contents are added. You need to use embedHTML or addList standalone to generate block contents inside other block contents.

Regards.