Forum


Replies: 2   Views: 3236
Paragraph styles ignored within 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 AndrewCooper  · 10-06-2016 - 11:12

I've got the following code...

$item1 = new WordFragment($docx);
$item1->addText('Chapter 1', array('pStyle' => 'Heading1PHPDOCX'));
$item2 = new WordFragment($docx);
$item2->addText('Section', array('pStyle' => 'Heading2PHPDOCX'));
$item3 = new WordFragment($docx);
$item3->addText('Another TOC entry', array('pStyle' => 'Heading3PHPDOCX'));

$itemList= array(
    $item1,
    array(
        $item2,
        array($item3)
    )
);

$docx->addList($itemList);

While this adds the correct text to the List, it ignores the pStyle.  It just gets created in the default font and style.  How do I get the List to preserve the pStyle?  I need those items to be in Heading 1, Heading 2, etc.

Andrew

Posted by admin  · 10-06-2016 - 13:09

Hello,

When using addList, all paragraphs use the same paragraph style. You can style the added text using dynamic styles properties available in addText or using a list style.

We also have a patch, that hasn't been released yet in the stable package, to allow to use pStyle in addText within addList. After you have purchased a license please write to contact[at]phpdocx.com and we'll send you the patch.

Regards.

Posted by AndrewCooper  · 10-06-2016 - 13:59

Cool.  Will defintely be wanting that patch.  Thanks.

 

Andrew