From 7f78322d043b3e26c2ae6b8ecdb269ba2f886e9f Mon Sep 17 00:00:00 2001 From: joelgo Date: Wed, 17 Mar 2021 13:09:13 -0500 Subject: [PATCH] Update html.php For acept text in line-height how "line-height:normal", etc. --- src/PhpWord/Shared/Html.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/PhpWord/Shared/Html.php b/src/PhpWord/Shared/Html.php index eabd102d..d5a5b657 100644 --- a/src/PhpWord/Shared/Html.php +++ b/src/PhpWord/Shared/Html.php @@ -661,7 +661,21 @@ class Html break; case 'line-height': $matches = array(); - if (preg_match('/([0-9]+\.?[0-9]*[a-z]+)/', $cValue, $matches)) { + if (preg_match('/([a-z]+)/', $cValue, $matches)) { + //$cvalue text and not number + if($cValue == 'normal') { + $cValue = 1.12; + $spacingLineRule = \PhpOffice\PhpWord\SimpleType\LineSpacingRule::AUTO; + //we are subtracting 1 line height because the Spacing writer is adding one line + $spacing = ($cValue * Paragraph::LINE_HEIGHT) - Paragraph::LINE_HEIGHT; + }else{ + $cValue = 1.13; + $spacingLineRule = \PhpOffice\PhpWord\SimpleType\LineSpacingRule::AUTO; + //we are subtracting 1 line height because the Spacing writer is adding one line + $spacing = ($cValue * Paragraph::LINE_HEIGHT) - Paragraph::LINE_HEIGHT; + } + } + elseif (preg_match('/([0-9]+\.?[0-9]*[a-z]+)/', $cValue, $matches)) { //matches number with a unit, e.g. 12px, 15pt, 20mm, ... $spacingLineRule = \PhpOffice\PhpWord\SimpleType\LineSpacingRule::EXACT; $spacing = Converter::cssToTwip($matches[1]);