Forum


Replies: 4   Views: 306
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 admin  · 18-08-2023 - 23:39

Hello,

When a block type replacement is done, the whole paragraph is removed to add the new block content.
Also note that some default styles (such as the font size) are applied when transforming HTML.

You can set the styles to be applied (such as the line spacing and the font size) to the imported HTML (using CSS styles). Or you can set the stylesReplacementType option (available in Premium licenses) as mixPlaceholderStyles to mix them. In this case you may need to also use the stylesReplacementTypeIgnore option.

For example:

// ignore font size when mixing the styles
$docx->replaceVariableByHTML('ADDRESS', 'block', '<p>phpdocx by <b>2mdc</b></p>', array('stylesReplacementType' => 'mixPlaceholderStyles', 'stylesReplacementTypeIgnore' => array('w:sz', 'w:szCs')));

In the Templates/replaceVariableByHTML folder available in the package you can find some samples. The addDefaultStyles option removes as many default styles as possible, but it doesn't mix styles.

If you sent to contact[at]phpdocx.com the DOCX template and the simplest script using phpdocx standalone, we'll check it.

Regards.