Replies: 2   Views: 2336
Use addlist with embedded html containing a 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 plintsites  · 25-01-2019 - 16:08


I am trying to make a word document with a nested list. The contents of sublist items are HTML, coming from a wysiwyg editor. Hence, this content may contain lists (ul's and/or ol's) also. It seems that this content does not load correctly.

To elaborate a bit on the subject I tweaked the addList example #3 from the docs a little, see below

$docx = new \Phpdocx\Create\CreateDocx();

$textData = new \Phpdocx\Elements\WordFragment($docx);
        $text = array();
        $text[] = array('text' => 'We insert some ');
        $text[] = array('text' => 'bold text', 'b' => 'on');

        // also, some simple HTML to illustrate the fexibility of the method
        $htmlData = new \Phpdocx\Elements\WordFragment($docx);
        $html = '<i>Some HTML code</i> with a <a href="">link</a>';

        // And some more complex HTML containing a list itself
        $htmlList = new \Phpdocx\Elements\WordFragment($docx);
                                        <li>100 m</li>
                                        <li>road cycling</li>

        $itemList= array(
            'In this example we use a custom list (val = 5) that comes bundled with the default phpdocx template.',
                'Line B',
                'Line C'
            'Line 3',
            'And now some more complex HTML using an unordered list...',

        // Add list to doc
        $docx->addList($itemList, 2);

In the resulting word document, the content of the $htmlList variable is not shown as a list.

I am very curious if it is possible to achieve what I am describing here.


With kind regards!