Forum


Replies: 12   Views: 3704
Custom list style issues
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  · 12-09-2017 - 15:50

Hello,

The left option is working fine, you can test it running this simple sample:

<?php

require_once 'classes/CreateDocx.inc';

$docx = new CreateDocx();
// custom options
$latinListOptions = array();
$latinListOptions[0]['type'] = 'lowerLetter';
$latinListOptions[0]['format'] = '%1.';
$latinListOptions[0]['left'] = 1;
$latinListOptions[1]['type'] = 'lowerRoman';
$latinListOptions[1]['format'] = '%1.%2.';

// create the list style with name: latin
$docx->createListStyle('latin', $latinListOptions);

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

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

// save the Word document
$docx->createDocx('example_createListStyle_1');

But it seems the problem is that you are not setting the list style to the list of the HTML. The customListStyles option doesn't assign a style ID to a list, you need to use the wordStyles option. there're some samples of this property on this page:

https://www.phpdocx.com/documentation/introduction/html-to-word-PHP

Or you can use DOCXCustomizer to change the style ID of a list:

https://www.phpdocx.com/api-documentation/docxcustomizer/customize-docx-Word-documents-PHP

Or use the addList method instead of HTML if you want to have more control:

https://www.phpdocx.com/api-documentation/word-content/insert-list-nested-Word-document-with-PHP

About inline and block types we just explaining that could be useful for some replacements, not your exact case.

Regards.