fix when style line-height size comes in decimal number
This commit is contained in:
parent
65a594d271
commit
fe647f6e55
|
|
@ -17,9 +17,12 @@
|
|||
<h2>Includes images</h2>
|
||||
<img src="https://phpword.readthedocs.io/en/latest/_images/phpword.png" alt=""/>
|
||||
|
||||
<img src="https://localhost/gev/desarrollo/actividades/pruebas_14/5b064503587f7.jpeg" name="Imagen 12" align="bottom" width="208" height="183" border="0"/>
|
||||
<img src="http://localhost/gev/desarrollo/actividades/pruebas_14/5b064503589db.png" name="Imagen 13" align="bottom" width="143" height="202" border="0"/>
|
||||
<img src="http://localhost/gev/desarrollo/actividades/pruebas_14/5b0645035aac8.jpeg" name="Imagen 14" align="bottom" width="194" height="188" border="0"/>
|
||||
<h2>Nested p and i</h2>
|
||||
<p class="western" align="right" style="font-weight: normal; line-height: 0.17in; orphans: 0; widows: 0">
|
||||
Contenido
|
||||
<font size="2" style="font-size: 9pt"><i>B.O. de la Provincia de Barcelona</i></font>
|
||||
<font size="2" style="font-size: 9pt">, 6-9-1939, citado en Díaz Plaja, F.: "España 1939-1979",</font>
|
||||
</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -530,7 +530,7 @@ class Html
|
|||
$styles['bgColor'] = trim($cValue, '#');
|
||||
break;
|
||||
case 'line-height':
|
||||
if (preg_match('/([0-9]+[a-z]+)/', $cValue, $matches)) {
|
||||
if (preg_match('/([0-9]+\.?[0-9]*[a-z]+)/', $cValue, $matches)) {
|
||||
$spacingLineRule = \PhpOffice\PhpWord\SimpleType\LineSpacingRule::EXACT;
|
||||
$spacing = Converter::cssToTwip($matches[1]) / \PhpOffice\PhpWord\Style\Paragraph::LINE_HEIGHT;
|
||||
} elseif (preg_match('/([0-9]+)%/', $cValue, $matches)) {
|
||||
|
|
|
|||
|
|
@ -126,6 +126,7 @@ class ConverterTest extends \PHPUnit\Framework\TestCase
|
|||
$this->assertEquals(10, Converter::cssToPoint('10pt'));
|
||||
$this->assertEquals(7.5, Converter::cssToPoint('10px'));
|
||||
$this->assertEquals(720, Converter::cssToPoint('10in'));
|
||||
$this->assertEquals(7.2, Converter::cssToPoint('0.1in'));
|
||||
$this->assertEquals(120, Converter::cssToPoint('10pc'));
|
||||
$this->assertEquals(28.346457, Converter::cssToPoint('10mm'), '', 0.000001);
|
||||
$this->assertEquals(283.464567, Converter::cssToPoint('10cm'), '', 0.000001);
|
||||
|
|
|
|||
|
|
@ -141,6 +141,7 @@ class HtmlTest extends \PHPUnit\Framework\TestCase
|
|||
Html::addHtml($section, '<p style="line-height: 1.5;">test</p>');
|
||||
Html::addHtml($section, '<p style="line-height: 15pt;">test</p>');
|
||||
Html::addHtml($section, '<p style="line-height: 120%;">test</p>');
|
||||
Html::addHtml($section, '<p style="line-height: 0.17in;">test</p>');
|
||||
|
||||
$doc = TestHelperDOCX::getDocument($phpWord, 'Word2007');
|
||||
$this->assertTrue($doc->elementExists('/w:document/w:body/w:p[1]/w:pPr/w:spacing'));
|
||||
|
|
@ -154,6 +155,10 @@ class HtmlTest extends \PHPUnit\Framework\TestCase
|
|||
$this->assertTrue($doc->elementExists('/w:document/w:body/w:p[3]/w:pPr/w:spacing'));
|
||||
$this->assertEquals(Paragraph::LINE_HEIGHT * 1.2, $doc->getElementAttribute('/w:document/w:body/w:p[3]/w:pPr/w:spacing', 'w:line'));
|
||||
$this->assertEquals(LineSpacingRule::AUTO, $doc->getElementAttribute('/w:document/w:body/w:p[3]/w:pPr/w:spacing', 'w:lineRule'));
|
||||
|
||||
$this->assertTrue($doc->elementExists('/w:document/w:body/w:p[4]/w:pPr/w:spacing'));
|
||||
$this->assertEquals(244.8, $doc->getElementAttribute('/w:document/w:body/w:p[4]/w:pPr/w:spacing', 'w:line'));
|
||||
$this->assertEquals(LineSpacingRule::EXACT, $doc->getElementAttribute('/w:document/w:body/w:p[4]/w:pPr/w:spacing', 'w:lineRule'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue