Forum


Replies: 6   Views: 2196
Display text with double underline
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  · 27-03-2019 - 15:44

Hello,

The best and easiest solution is using a Premium license, that includes HTML Extended features. For this specific case, you can do a minor change in the library:

Edit HTML2WordML.php in the classes folder, and in the method generateRPr (around line 1859), add these lines after the line-through check:

if (isset($properties['text_decoration']) && $properties['text_decoration'] == 'double-underline') {
    $stringRPr .='<w:u w:val="double" />';
}

Instead of this code:

if (isset($properties['text_decoration']) && $properties['text_decoration'] == 'line-through') {
    $stringRPr .='<w:strike />';
}
if (!$this->strictWordStyles) {

this is the code updated:

if (isset($properties['text_decoration']) && $properties['text_decoration'] == 'line-through') {
    $stringRPr .='<w:strike />';
}
if (isset($properties['text_decoration']) && $properties['text_decoration'] == 'double-underline') {
    $stringRPr .='<w:u w:val="double" />';
}
if (!$this->strictWordStyles) {

After this change, you can use the custom double-underline value to apply a double underline style in texts:

$html = '
<style>
    .underline {
        text-decoration: underline;
    }
    .dunderline {
        text-decoration: double-underline;
    }
</style>
';
$html .= '<p><span class="underline">Underline</span> and <span class="dunderline">double underline</span>.</p>';
$docx->embedHTML($html);

Regards.