Forum


Replies: 3   Views: 2079
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 - 15:34

Hello,

First line indentation isn't a numbering property but a paragraph one.

phpdocx doesn't support applying first line indentation to li tags through CSS, only paragraph (p) tags and list-style-type: none are supported. You can accomplish it using HTML Extended available in Premium licenses with the data-listppr property:

$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);

$indentation = htmlentities('<w:ind w:left="680" w:firstLine="357" />');

$html = '
<ul class="mylist">
    <li>TEXT TEXT TEXT.</li>
    <br>
    <ul>
        <li data-listppr="'.$indentation.'"><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 data-listppr="'.$indentation.'"><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 data-listppr="'.$indentation.'"><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 data-listppr="'.$indentation.'"><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, 'useHTMLExtended' => true));

Please note that MS Word has some limitations when mixing paragraph and numbering indentations such as trying to apply a hanging when setting the first line paragraph style. You can check them trying to create that list with MS Word.

Regards.