Forum


Replies: 1   Views: 2428
Line height and styles
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  · 03-04-2019 - 10:01

Hello,

The line-height is applied based on the twips. If documents are using a w:lineRule with atLeast value, then the line-height may be very low.

To prevent this, we recommend you to apply the following change:

In the TransformDocAdvHTML.php file, go to the addPprStyles method, and instead of:

if ($pprStyle->hasAttribute('w:line')) {
    $styles .= 'line-height: ' . $this->htmlPlugin->transformSizes($pprStyle->getAttribute('w:line'), 'twips') . ';';
}

You can use:

if ($pprStyle->hasAttribute('w:line')) {
    if (!$pprStyle->hasAttribute('w:lineRule')) {
        $styles .= 'line-height: ' . $this->htmlPlugin->transformSizes($pprStyle->getAttribute('w:line'), 'twips') . ';';
    }
}

That prevents adding the line-height if w:lineRule is set.

You can also use DOCXCustomizer and getWordStyles to read, parse and change/normalize existing styles if needed.

Regards.