From e27e80c440fe68593fd2a33affb06c9382de3ef0 Mon Sep 17 00:00:00 2001 From: rasamassen Date: Mon, 29 Sep 2025 09:27:27 -0500 Subject: [PATCH 1/2] Update Section.php - Add Columns and BreakTypes (and don't needlessly set Gutter if default) --- src/PhpWord/Writer/RTF/Style/Section.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/PhpWord/Writer/RTF/Style/Section.php b/src/PhpWord/Writer/RTF/Style/Section.php index 598015ed4d..1199a93345 100644 --- a/src/PhpWord/Writer/RTF/Style/Section.php +++ b/src/PhpWord/Writer/RTF/Style/Section.php @@ -53,8 +53,23 @@ public function write() $content .= $this->getValueIf($style->getMarginLeft() !== null, '\marglsxn' . round($style->getMarginLeft())); $content .= $this->getValueIf($style->getHeaderHeight() !== null, '\headery' . round($style->getHeaderHeight())); $content .= $this->getValueIf($style->getFooterHeight() !== null, '\footery' . round($style->getFooterHeight())); - $content .= $this->getValueIf($style->getGutter() !== null, '\guttersxn' . round($style->getGutter())); + $content .= $this->getValueIf($style->getGutter() !== null && $style->getGutter() !== SectionStyle::DEFAULT_GUTTER, '\guttersxn' . round($style->getGutter())); $content .= $this->getValueIf($style->getPageNumberingStart() !== null, '\pgnstarts' . $style->getPageNumberingStart() . '\pgnrestart'); + $content .= $this->getValueIf($style->getColsNum() !== null && $style->getColsNum() !== SectionStyle::DEFAULT_COLUMN_COUNT, '\cols' . $style->getColsNum()); + $content .= $this->getValueIf($style->getColsSpace() !== null && $style->getColsNum() !== SectionStyle::DEFAULT_COLUMN_COUNT, '\colsx' . round($style->getColsSpace())); + + // Break Type + $breakTypes = [ + 'nextPage' => '\sbkpage', + 'nextColumn' => '\sbkcol', + 'continuous' => '\sbknone', + 'evenPage' => '\sbkeven', + 'oddPage' => '\sbkodd', + ]; + if (isset($breakTypes[$style->getBreakType()])) { + $content .= $breakTypes[$style->getBreakType()]; + } + $content .= ' '; // Borders From 82698c11937a763a90db0fa6bbf3a9cac7615a79 Mon Sep 17 00:00:00 2001 From: rasamassen Date: Mon, 29 Sep 2025 09:35:06 -0500 Subject: [PATCH 2/2] Update 1.5.0.md --- 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..9f74d15e72 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 columns and breakType in Section by [@rasamassen](https://github.com/rasamassen) in [#2835](https://github.com/PHPOffice/PHPWord/pull/2835) ### Miscellaneous @@ -16,4 +17,4 @@ ### BC Breaks -### Notes \ No newline at end of file +### Notes