Forum


Replies: 1   Views: 963
Left margin/padding of ol and ul lists
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 NylonDerek  · 16-05-2022 - 19:13

Hello,

I'm using phpdocx 12.5 premium to embed HTML in word docs.

Is it possible to globally set the left margin/padding of OL and UL lists without applying a custom class to them? All attempts to do this using CSS have not worked.

Example code that does not affect left margin/padding:

<ul style="margin-left: 0; padding-left: 0;">
  <li>List Item 1</li>
  <li>List Item 2</li>
  <li>List Item 3</li>
</ul>

Thanks!

Posted by admin  · 17-05-2022 - 05:45

Hello,

To set left margins to list items when importing HTML a custom list style must be used:

$myListStyle = array();
$myListStyle[0]['left'] = 900;
$docx->createListStyle('myliststyle', $myListStyle);

$html = '
<ul class="myliststyle">
    <li>First item.</li>
    <li>Second item.</li>
    <li>Third item.</li>
</ul>';
$docx->embedHTML($html, array('customListStyles' => true));

Changing left margins of list items isn't supported applying CSS styles. Paragraphs and other elements support setting custom margins using CSS styles.

Regards.