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 diff --git a/src/PhpWord/Writer/RTF/Style/Section.php b/src/PhpWord/Writer/RTF/Style/Section.php index 598015ed4d..cb0138dbda 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