Repository navigation
fix(docx): draw a one-page section's backgrounds from the body, so LibreOffice sets it where the page does - #833
Merged
Merged
Conversation
…breOffice sets it where the page does
DemchaAV
marked this pull request as draft
October 3, 2026 20:03
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The DOCX export paints a session's page backgrounds as page-anchored rectangles in the section's header. When the section has no header of its own, it gets an empty one against the page edge to carry them.
LibreOffice gives a header a height of its own, however little it holds, and sets the body that much lower. Every line of the seven sidebar CVs, whose column is a page background, stood 2.6 to 3.3pt low in LibreOffice:
SlateOrange,CharcoalGold,MidnightNavy,NavySidebar,ProfessionalSidebar,SidebarPortraitandMonogramSidebar. That came to 479 of the corpus's 606 LibreOffice lines more than 2pt off. In Word there was no shift.Just dropping the header does not work. A page laid out as one table opens with a hairline paragraph, which carries the page's shapes because the body has no other paragraph. Over a row as tall as the page, that 0.1pt pushed the row onto a second page in LibreOffice.
What changed
DocxSemanticBackend.applyPageBackgrounds. A section whose layout is one page, with no header and no footer, writes no header. Its fills are kept for the body.reportDrawingsLeftOveranchors those fills on the page:DocxPageBackgrounds.drawing(…, inHeader). In the body a fill islayoutInCell="0"and notlocked, so it is laid out from the page even when its anchor is a cell's paragraph. It keeps its 1024·n stack height, under every other body shape (251658240+).MeteredInvoice's footer band hid its footer text, andConsultingInvoice's andRotaCobalt's footers vanished too.DocxDrawingAnchors.bodyParagraphOn/cellParagraphOn.Shapes anchored in a cell: #768 recorded Word printing such a shape clipped to the cell. With Word 16.0.20430 I could not reproduce that, in either Word's PDF export or a screen capture of the document. The cases checked were:
DocxDrawingsTestwith a page background (the ring stands outside the sidebar cell it is anchored in);The page-0 shapes of these seven now ride in their first cell.
Verification
-Dgraphcompose.docxFidelity=libreoffice.update=true; the Linux baseline is this PR's CI artifactdocx-fidelity-37149422121, which moved the same seven CVs the same way (corpus 724 → 245 lines past 2pt) and nothing else.scripts/docx-visual/word-fidelity.ps1→ BUILD SUCCESS, baseline rewritten with-Update.SlateOrangeandMidnightNavymatches.DocxPageBackgroundTest, +3 tests (12):layoutInCell="0", with no hairline over the table;DocxDrawingsTest.theBodysDrawingsStandAboveThePageBackgroundsreads the fills from body and header alike../mvnw -B -ntp clean verify -pl :graph-compose-core,:graph-compose-render-pdf,:graph-compose-render-docx,:graph-compose-render-pptx,:graph-compose-templates,:graph-compose-testing,:graph-compose-qa,:graph-compose-coverage -am→ BUILD SUCCESS.CommittedAssetDriftTestinexamples→ 3/3 green.Trade-off and known limits
Lane: shared-engine (render-docx). DOCX export only, no public API change.