Forum


Replies: 3   Views: 1875
Lists' indentations
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 admin  · 25-03-2020 - 11:23

Hello,

You need to use left and hanging options available in createListStyle. For example:

$docx = new CreateDocx();

$latinListOptions = array();
$latinListOptions[0]['type'] = 'upperLetter';
$latinListOptions[0]['format'] = '%1.';
$latinListOptions[0]['left'] = 1440;
$latinListOptions[0]['hanging'] = 720;
$latinListOptions[1]['type'] = 'decimal';
$latinListOptions[1]['format'] = '%2.';
$latinListOptions[1]['left'] = 2160;
$latinListOptions[1]['hanging'] = 720;
$docx->createListStyle('mylist', $latinListOptions);

$html = '
<ul class="mylist">
    <li>TEXT TEXT TEXT.</li>
    <br>
    <ul>
        <li><span style="text-decoration: underline;">TEXT</span>. Text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text.</li>
        <li><span style="text-decoration: underline;">TEXT</span>. Text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text.</li>
    </ul>
    <li>TEXT TEXT TEXT.</li>
    <br>
    <ul>
        <li><span style="text-decoration: underline;">TEXT</span>. Text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text.</li>
        <li><span style="text-decoration: underline;">TEXT</span>. Text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text.</li>
    </ul>
</ul>';
$docx->embedHTML($html, array('customListStyles' => true));

Please note that you can also create a custom list style using MS Word and import it using importListStyle to be applied when transforming HTML.

About hanging, from the documentation page:

hanging  int  The extra space for the numbering, should be big enough to accommodate it, the default is 360.

It's the space used by the numbering before the item contents. Both options are set using twips (integer value) (https://wordribbon.tips.net/T011388_Words_Native_Measurement_Unit.html).

Regards.