From cd7d1a26d2ac607bff0398361bd7ee0d8ecb4fd9 Mon Sep 17 00:00:00 2001 From: Progi1984 Date: Wed, 29 Jan 2025 12:51:42 +0100 Subject: [PATCH 1/3] Reader HTML: Support for inherit value for property line-height (#2733) --- docs/changes/1.x/1.4.0.md | 5 +++-- src/PhpWord/Shared/Html.php | 2 +- tests/PhpWordTests/Shared/HtmlTest.php | 5 +++++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/docs/changes/1.x/1.4.0.md b/docs/changes/1.x/1.4.0.md index c8a019115d..8c2651c8b7 100644 --- a/docs/changes/1.x/1.4.0.md +++ b/docs/changes/1.x/1.4.0.md @@ -20,8 +20,9 @@ - Writer ODText: Support for images inside a textRun by [@Progi1984](https://github.com/Progi1984) fixing [#2240](https://github.com/PHPOffice/PHPWord/issues/2240) in [#2668](https://github.com/PHPOffice/PHPWord/pull/2668) - Allow vAlign and vMerge on Style\Cell to be set to null by [@SpraxDev](https://github.com/SpraxDev) fixing [#2673](https://github.com/PHPOffice/PHPWord/issues/2673) in [#2676](https://github.com/PHPOffice/PHPWord/pull/2676) - Reader HTML: Support for differents size units for table by [@Progi1984](https://github.com/Progi1984) fixing [#2384](https://github.com/PHPOffice/PHPWord/issues/2384), [#2701](https://github.com/PHPOffice/PHPWord/issues/2701) in [#2725](https://github.com/PHPOffice/PHPWord/pull/2725) -- Reader Word2007 : Respect paragraph indent units by [@tugmaks](https://github.com/tugmaks) & [@Progi1984](https://github.com/Progi1984) fixing [#507](https://github.com/PHPOffice/PHPWord/issues/507) in [#2726](https://github.com/PHPOffice/PHPWord/pull/2726) -- Reader Word2007 : Support Header elements within Title elements by [@SpraxDev](https://github.com/SpraxDev) fixing [#2616](https://github.com/PHPOffice/PHPWord/issues/2616), [#2426](https://github.com/PHPOffice/PHPWord/issues/2426) in [#2674](https://github.com/PHPOffice/PHPWord/pull/2674) +- Reader Word2007: Respect paragraph indent units by [@tugmaks](https://github.com/tugmaks) & [@Progi1984](https://github.com/Progi1984) fixing [#507](https://github.com/PHPOffice/PHPWord/issues/507) in [#2726](https://github.com/PHPOffice/PHPWord/pull/2726) +- Reader Word2007: Support Header elements within Title elements by [@SpraxDev](https://github.com/SpraxDev) fixing [#2616](https://github.com/PHPOffice/PHPWord/issues/2616), [#2426](https://github.com/PHPOffice/PHPWord/issues/2426) in [#2674](https://github.com/PHPOffice/PHPWord/pull/2674) +- Reader HTML: Support for inherit value for property line-height by [@Progi1984](https://github.com/Progi1984) fixing [#2683](https://github.com/PHPOffice/PHPWord/issues/2683) in [#2733](https://github.com/PHPOffice/PHPWord/pull/2733) ### Miscellaneous diff --git a/src/PhpWord/Shared/Html.php b/src/PhpWord/Shared/Html.php index 4573daf2a9..cdaf8d8c87 100644 --- a/src/PhpWord/Shared/Html.php +++ b/src/PhpWord/Shared/Html.php @@ -741,7 +741,7 @@ protected static function parseStyleDeclarations(array $selectors, array $styles break; case 'line-height': $matches = []; - if ($value === 'normal') { + if ($value === 'normal' || $value === 'inherit') { $spacingLineRule = \PhpOffice\PhpWord\SimpleType\LineSpacingRule::AUTO; $spacing = 0; } elseif (preg_match('/([0-9]+\.?[0-9]*[a-z]+)/', $value, $matches)) { diff --git a/tests/PhpWordTests/Shared/HtmlTest.php b/tests/PhpWordTests/Shared/HtmlTest.php index 7551f51cb8..117f5cb01d 100644 --- a/tests/PhpWordTests/Shared/HtmlTest.php +++ b/tests/PhpWordTests/Shared/HtmlTest.php @@ -249,6 +249,7 @@ public function testParseLineHeight(): void Html::addHtml($section, '

test

'); Html::addHtml($section, '

test

'); Html::addHtml($section, '

test

'); + Html::addHtml($section, '

test

'); $doc = TestHelperDOCX::getDocument($phpWord, 'Word2007'); self::assertTrue($doc->elementExists('/w:document/w:body/w:p[1]/w:pPr/w:spacing')); @@ -270,6 +271,10 @@ public function testParseLineHeight(): void self::assertTrue($doc->elementExists('/w:document/w:body/w:p[5]/w:pPr/w:spacing')); self::assertEquals(Paragraph::LINE_HEIGHT, $doc->getElementAttribute('/w:document/w:body/w:p[5]/w:pPr/w:spacing', 'w:line')); self::assertEquals(LineSpacingRule::AUTO, $doc->getElementAttribute('/w:document/w:body/w:p[5]/w:pPr/w:spacing', 'w:lineRule')); + + self::assertTrue($doc->elementExists('/w:document/w:body/w:p[6]/w:pPr/w:spacing')); + self::assertEquals(Paragraph::LINE_HEIGHT, $doc->getElementAttribute('/w:document/w:body/w:p[6]/w:pPr/w:spacing', 'w:line')); + self::assertEquals(LineSpacingRule::AUTO, $doc->getElementAttribute('/w:document/w:body/w:p[6]/w:pPr/w:spacing', 'w:lineRule')); } public function testParseCellPaddingStyle(): void From 3b12b4e902b746d43699d8ac9e15414a18f03171 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=B7=D0=B0=D0=BC=D0=B0=D1=828405?= Date: Wed, 29 Jan 2025 14:59:45 +0300 Subject: [PATCH 2/3] Documentation : Improved `docs/usage/writers.md` (#2732) * Update composer.json azamat8405/phpword * fix: package name * feat: addition in documentation related to phpword.ini * Update docs/usage/writers.md Co-authored-by: Progi1984 --------- Co-authored-by: OlisaevAG Co-authored-by: Progi1984 --- docs/usage/writers.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/usage/writers.md b/docs/usage/writers.md index f561345a95..97708a0294 100644 --- a/docs/usage/writers.md +++ b/docs/usage/writers.md @@ -110,6 +110,13 @@ Settings::setPdfRendererName(Settings::PDF_RENDERER_MPDF); Settings::setPdfRendererPath(__DIR__ . '/../vendor/mpdf/mpdf'); ``` +or you can edit settings in phpword.ini ( or phpword.ini.dist) file. + +``` ini +pdfRendererName = MPDF ;DomPDF, TCPDF, MPDF +pdfRendererPath = /path/to/your/renderer/folder +``` + ## RTF The name of the writer is `RTF`. From 269a81034090cee09b43627ab25986ba194e1792 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=B7=D0=B0=D0=BC=D0=B0=D1=828405?= Date: Wed, 29 Jan 2025 19:40:24 +0300 Subject: [PATCH 3/3] Documentation : Improved docs/install.md (#2734) * Update composer.json azamat8405/phpword * fix: package name * Documentation : Improved docs/install.md --------- Co-authored-by: OlisaevAG --- docs/install.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/docs/install.md b/docs/install.md index a4d61b104d..4e485bf739 100644 --- a/docs/install.md +++ b/docs/install.md @@ -45,6 +45,26 @@ require_once 'path/to/PHPWord/src/PhpWord/Autoloader.php'; The preferred method is the Composer one. +### Configuration + +In order to configure you can create phpword.ini file and load configuration by calling Settings::loadConfig + +``` php +