Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/changes/1.x/1.5.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -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: Add mirror margins and bookfold capabilities by [@rasamassen](https://github.com/rasamassen) in [#2834](https://github.com/PHPOffice/PHPWord/pull/2834)

### Miscellaneous

Expand All @@ -16,4 +17,4 @@

### BC Breaks

### Notes
### Notes
8 changes: 7 additions & 1 deletion src/PhpWord/Writer/RTF/Part/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,15 @@ private function writeFormatting()
$content .= '\lang' . $langId;
$content .= '\kerning1'; // Point size (in half-points) above which to kern character pairs
$content .= '\fs' . (Settings::getDefaultFontSize() * 2); // Set the font size in half-points
if ($docSettings->hasEvenAndOddHeaders()) {
if ($docSettings->hasEvenAndOddHeaders() || $docSettings->hasMirrorMargins()) {
$content .= '\\facingp';
}
if ($docSettings->hasMirrorMargins()) {
$content .= '\\margmirror';
}
if ($docSettings->hasBookFoldPrinting()) {
$content .= '\\bookfold\\landscape';
}
$content .= PHP_EOL;

return $content;
Expand Down
12 changes: 10 additions & 2 deletions src/PhpWord/Writer/RTF/Style/Section.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,16 @@ public function write()
$content .= '\sectd ';

// Size & margin
$content .= $this->getValueIf($style->getPageSizeW() !== null, '\pgwsxn' . round($style->getPageSizeW()));
$content .= $this->getValueIf($style->getPageSizeH() !== null, '\pghsxn' . round($style->getPageSizeH()));
if ($this->getParentWriter() !== null && $this->getParentWriter()->getPhpWord()->getSettings()->hasBookFoldPrinting()) {
if ($style->getOrientation() !== SectionStyle::ORIENTATION_LANDSCAPE) {
$style->setOrientation(SectionStyle::ORIENTATION_LANDSCAPE);
}
$content .= $this->getValueIf($style->getPageSizeW() !== null, '\pgwsxn' . round($style->getPageSizeW()) / 2);
$content .= $this->getValueIf($style->getPageSizeH() !== null, '\pghsxn' . round($style->getPageSizeH()));
} else {
$content .= $this->getValueIf($style->getPageSizeW() !== null, '\pgwsxn' . round($style->getPageSizeW()));
$content .= $this->getValueIf($style->getPageSizeH() !== null, '\pghsxn' . round($style->getPageSizeH()));
}
$content .= ' ';
$content .= $this->getValueIf($style->getMarginTop() !== null, '\margtsxn' . round($style->getMarginTop()));
$content .= $this->getValueIf($style->getMarginRight() !== null, '\margrsxn' . round($style->getMarginRight()));
Expand Down
Loading