Skip to content

fix(docx): state a landscape page as landscape - #723

Merged
DemchaAV merged 1 commit into
2.5-devfrom
fix/docx-page-orientation
Sep 23, 2026
Merged

DemchaAV merged 1 commit into
2.5-devfrom
fix/docx-page-orientation

Conversation

@DemchaAV

Copy link
Copy Markdown
Owner

Why

DocxSemanticBackend.applyPageGeometry wrote the page's real width and height into w:pgSz but always set w:orient="portrait". Word draws the page from w:w / w:h, so a landscape document opened the right shape — but Page Setup showed it as portrait, and printing reads the orientation from w:orient, not from the dimensions.

What changed

  • applyPageGeometry sets LANDSCAPE when the canvas is wider than it is tall, PORTRAIT otherwise. Width and height stay exactly as the layout gives them — Word does not swap them for landscape, it expects w:w > w:h together with orient="landscape".
  • A square page stays portrait, which is how Word itself states one.
  • docs/recipes/docx-export.md names orientation alongside size and margins; CHANGELOG entry under v2.5.0.

Verification

./mvnw -B -ntp clean verify over the reactor → BUILD SUCCESS (1788 tests in the main run, 127 render-docx), then install + all examples regenerated (93 green).

New DocxPageOrientationTest (3 tests): an 842×595 page is LANDSCAPE with w:w/w:h unchanged in twips; 595×842 is PORTRAIT; 600×600 is PORTRAIT. Reverting the one-line change fails the landscape test.

Lane: shared-engine (render-docx) — page section properties only; no public API change.

Word draws a page from w:w and w:h but reads the orientation from
w:orient for Page Setup and printing. The export wrote portrait for
every page. A page wider than it is tall is now LANDSCAPE; a square
page stays PORTRAIT.
@DemchaAV
DemchaAV merged commit 0c1b4eb into 2.5-dev Sep 23, 2026
12 checks passed
@DemchaAV
DemchaAV deleted the fix/docx-page-orientation branch September 23, 2026 12:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant