Forum


Replies: 2   Views: 775
Createliststyle ignores fontsize option, changes to my default.
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 skwirrel  · 24-05-2022 - 08:25

What do we have to do, that this does not ignores the fontsize option?

 

$this->docx->createListStyle('inclusion', [0 => [
        'type'     => 'decimal', // ordered list
        'align'    => 'right',   // align numbers to the right
        'fontSize' => 10,        // this seems to be ignored
        'font'     => 'Calibri',
        'suff'     => 'space',   // space between list number and text
    ]]
);
$this->docx->addList($list, 'inclusion');

Posted by admin  · 24-05-2022 - 09:11

Hello,

We have run the following code:

$docx = new CreateDocx();

$docx->createListStyle('inclusion', [
    0 => [
        'type'     => 'decimal', // ordered list
        'align'    => 'right',   // align numbers to the right
        'fontSize' => 10,        // this seems to be ignored
        'font'     => 'Calibri',
        'suff'     => 'space',   // space between list number and text
    ],
]);

// list items
$myList = array('item 1', array('subitem 1.1', 'subitem 1.2'), 'item 2');

// insert the custom list into the Word document
$docx->addList($myList, 'inclusion');

$docx->createDocx('output');

and the output is correct in all MS Word versions and LibreOffice.

If we set a higher value, the output is correct too:

$docx = new CreateDocx();

$docx->createListStyle('inclusion', [
    0 => [
        'type'     => 'decimal', // ordered list
        'align'    => 'right',   // align numbers to the right
        'fontSize' => 16,        // this seems to be ignored
        'font'     => 'Calibri',
        'suff'     => 'space',   // space between list number and text
    ],
]);

// list items
$myList = array('item 1', array('subitem 1.1', 'subitem 1.2'), 'item 2');

// insert the custom list into the Word document
$docx->addList($myList, 'inclusion');

$docx->createDocx('output');

Please note that this fontSize option sets the font size of the item list (bullet, decimal...), not the text content. To set styles of the text contents in a list you need to use WordFragments, please check the included sample: Core/addList/sample_3.php.

Regards.

Posted by skwirrel  · 24-05-2022 - 09:27

Oh I see, thank you.