Forum


Replies: 4   Views: 461
Custom list style & bold using html extended with stylesreplacementtype
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 tangamampilia  · 16-08-2023 - 17:22

Hi,

I'm trying to implement a custom list style with some tags inside. This is my sample code:

$docs = new CreateDocxFromTemplate('document.docx');

$docs->createListStyle('latin', [
        ['type' => 'decimal', 'format' => '%1.'],
        ['type' => 'lowerLetter', 'format' => '%2.'],
        ['type' => 'lowerRoman',  'format' => '%3.'],
]);

$html = '
<ul>
<li><b>Hello</b> World</li>
</ul>
';

$docs->replaceVariableByHTML('LIST', 'block', $html, ['stylesReplacementType' => 'mixPlaceholderStyles', 'disableWrapValue' => true, 'addDefaultStyles' => false, 'customListStyles' => true]);

If I change the addDefaultStyles to true, the bold text works but the rest of the styles (font size & line spacing) are also updated. If addDefaultStyles is false, then the bold fails and font size & line spacing works.

Do you have any suggestion? I have the premium license. 

Thanks!