Forum


Replies: 6   Views: 3362
Custom list style in embedhtml
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 gijs  · 24-08-2017 - 10:58

Deleted by gijs · 24-08-2017 - 13:24

Posted by admin  · 24-08-2017 - 11:10

Hello,

You need to add a class to the ul tag with the numbering ID value. This sample is working fine:

$listOptions = array();
$listOptions[0]['type'] = 'bullet';
$listOptions[0]['format'] = 'G';
$listOptions[0]['color'] = '0a46ba';
$listOptions[0]['font'] = 'Wingdings';
$listOptions[1]['type'] = 'bullet';
$listOptions[1]['color'] = '0a46ba';
$listOptions[1]['format'] = 'F';
$listOptions[1]['font'] = 'Wingdings';

$docx->createListStyle('bullet', $listOptions);

$html = 'a lot of html and a list <ul class="bullet"><li>example</li></ul> and a bit more html';

$docx->embedHTML($html, array('customListStyles' => true));

Which version and license of phpdocx are you using? And what program are you using to open the DOCX? We have tested it using MS Word and LibreOffice 5 and it opens perfectly (you need to install Wingdings font as you are using it).

Regards.

Posted by gijs  · 24-08-2017 - 12:12

You where very quick with your reply, i've editted my question to add the class to the list but no changes are visible. Using phpdocx 6.5, could that be the problem?

Posted by admin  · 24-08-2017 - 12:24

Hello,

Which license of phpdocx are you using (Trial, Basic, Advanced or Premium)? And what program are you using to open the DOCX? Using the previous code, we have tested it with MS Word and LibreOffice 5, and it shows the numbering style perfectly (you need to install Wingdings font as you are using it).

Regards.

Posted by gijs  · 24-08-2017 - 12:29

Using word 2016 and  theadvanced license if i'm not mistaking

Posted by gijs  · 24-08-2017 - 12:47

I figured it out, it does work when i use it toplevel but i'm using it in a addtable in a wordfragment

Posted by admin  · 24-08-2017 - 13:38

Hello,

It works too using WordFragments, but you need to add the numbering style to the WordFragment:

$htmlWordFragment = new WordFragment($docx);

$listOptions = array();
$listOptions[0]['type'] = 'bullet';
$listOptions[0]['format'] = 'G';
$listOptions[0]['color'] = '0a46ba';
$listOptions[0]['font'] = 'Wingdings';
$listOptions[1]['type'] = 'bullet';
$listOptions[1]['color'] = '0a46ba';
$listOptions[1]['format'] = 'F';
$listOptions[1]['font'] = 'Wingdings';

$htmlWordFragment->createListStyle('bullet', $listOptions);

$html = 'a lot of html and a list <ul class="bullet"><li>example</li></ul> and a bit more html';

$htmlWordFragment->embedHTML($html, array('customListStyles' => true));

$valuesTable = array(
    array(
        'Title A',
        'Title B',
        'Title C'
    ),
    array(
        'Line A',
        'Line B',
        $htmlWordFragment,
    )
);


$paramsTable = array(
    'tableStyle' => 'LightListAccent1PHPDOCX',
    'tableAlign' => 'center',
    'columnWidths' => array(1000, 2500, 3000),
    );

$docx->addTable($valuesTable, $paramsTable);

Regards.