From 7d17cb32c17f4a6847bb565d8e6dc284bb425361 Mon Sep 17 00:00:00 2001 From: rasamassen Date: Mon, 1 Sep 2025 10:20:19 -0500 Subject: [PATCH 1/3] verticalAlign in Section.php Adds missing verticalAlign settings. --- src/PhpWord/Writer/RTF/Style/Section.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/PhpWord/Writer/RTF/Style/Section.php b/src/PhpWord/Writer/RTF/Style/Section.php index 598015ed4d..e17e30a83d 100644 --- a/src/PhpWord/Writer/RTF/Style/Section.php +++ b/src/PhpWord/Writer/RTF/Style/Section.php @@ -55,6 +55,17 @@ public function write() $content .= $this->getValueIf($style->getFooterHeight() !== null, '\footery' . round($style->getFooterHeight())); $content .= $this->getValueIf($style->getGutter() !== null, '\guttersxn' . round($style->getGutter())); $content .= $this->getValueIf($style->getPageNumberingStart() !== null, '\pgnstarts' . $style->getPageNumberingStart() . '\pgnrestart'); + + // Vertical Align + $verticalAlign = [ + \PhpOffice\PhpWord\SimpleType\VerticalJc::TOP => '\vertalt', + \PhpOffice\PhpWord\SimpleType\VerticalJc::CENTER => '\vertalc', + \PhpOffice\PhpWord\SimpleType\VerticalJc::BOTH => '\vertalj', + \PhpOffice\PhpWord\SimpleType\VerticalJc::BOTTOM => '\vertalb', + ]; + if (isset($verticalAlign[$style->getVAlign()])) { + $content .= $verticalAlign[$style->getVAlign()]; + } $content .= ' '; // Borders From c38fd4ae694f9bc84383357e9460034cf16b395b Mon Sep 17 00:00:00 2001 From: rasamassen Date: Mon, 1 Sep 2025 19:10:07 -0500 Subject: [PATCH 2/3] Update Section.php - Fix formatting --- src/PhpWord/Writer/RTF/Style/Section.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PhpWord/Writer/RTF/Style/Section.php b/src/PhpWord/Writer/RTF/Style/Section.php index e17e30a83d..cb0138dbda 100644 --- a/src/PhpWord/Writer/RTF/Style/Section.php +++ b/src/PhpWord/Writer/RTF/Style/Section.php @@ -55,7 +55,7 @@ public function write() $content .= $this->getValueIf($style->getFooterHeight() !== null, '\footery' . round($style->getFooterHeight())); $content .= $this->getValueIf($style->getGutter() !== null, '\guttersxn' . round($style->getGutter())); $content .= $this->getValueIf($style->getPageNumberingStart() !== null, '\pgnstarts' . $style->getPageNumberingStart() . '\pgnrestart'); - + // Vertical Align $verticalAlign = [ \PhpOffice\PhpWord\SimpleType\VerticalJc::TOP => '\vertalt', From 9640e6198e84f225063374f767c86d2d49f9bd2a Mon Sep 17 00:00:00 2001 From: rasamassen Date: Mon, 1 Sep 2025 22:01:30 -0500 Subject: [PATCH 3/3] Update 1.5.0.md - Changelog for Pull 2817 --- docs/changes/1.x/1.5.0.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/changes/1.x/1.5.0.md b/docs/changes/1.x/1.5.0.md index b96865bada..b6eb255ff5 100644 --- a/docs/changes/1.x/1.5.0.md +++ b/docs/changes/1.x/1.5.0.md @@ -7,6 +7,7 @@ ### Bug fixes - Set writeAttribute return type by [@radarhere](https://github.com/radarhere) fixing [#2204](https://github.com/PHPOffice/PHPWord/issues/2204) in [#2776](https://github.com/PHPOffice/PHPWord/pull/2776) +- Writer RTF: Support for verticalAlign in Section by [@rasamassen](https://github.com/rasamassen) in [#2817](https://github.com/PHPOffice/PHPWord/pull/2817) ### Miscellaneous @@ -16,4 +17,4 @@ ### BC Breaks -### Notes \ No newline at end of file +### Notes