Skip to content

fix(engine): correct PageBackgroundFill y-coordinate for partial-height bands#75

Merged
DemchaAV merged 1 commit into
developfrom
fix/pagebackgroundfill-y-coordinate
May 29, 2026
Merged

fix(engine): correct PageBackgroundFill y-coordinate for partial-height bands#75
DemchaAV merged 1 commit into
developfrom
fix/pagebackgroundfill-y-coordinate

Conversation

@DemchaAV
Copy link
Copy Markdown
Owner

Summary

Fixes the PageBackgroundFill y-coordinate so a partial-height band lands where the API documents.

The bug

PlacedFragment.y is the PDF-native bottom-left origin (y grows up; PdfShapeFragmentRenderHandler calls addRect(x, y, w, h) with (x, y) as the bottom-left). DocumentPageBackgrounds.apply() set y = yRatio * pageHeight, so a band with yRatio = 0 — documented as the top edge — rendered at the bottom. Latent until now because every factory helper uses heightRatio = 1, where top and bottom are indistinguishable.

The fix

y = (1 - yRatio - heightRatio) * pageHeight. Full-page and full-height column fills resolve to y = 0 — unchanged, so existing fills and visual baselines are unaffected.

Test plan

  • 3 new regression tests: top / bottom / mid band placement (partial-height was previously untested)
  • PageBackgroundTest 13/13 green
  • mvnw clean verify -pl . — 997 tests, 0 failures (no visual baseline shifted)
  • CHANGELOG bug-fix entry under v1.6.5

Part of the v1.6.5 engine work (audit §4, variant A). PR-7 adds topBand / bottomBand / band factory helpers on top of this corrected coordinate model.

…ht bands

A page-background fill with heightRatio < 1.0 was painted from the page
bottom upward instead of from the documented yRatio top edge, so a band
with yRatio=0 rendered at the bottom of the page. PlacedFragment.y is the
PDF-native bottom-left origin (y grows up — see
PdfShapeFragmentRenderHandler), so the top-down ratios now convert via
y = (1 - yRatio - heightRatio) * pageHeight. Full-page and full-height
column fills resolve to y=0, unchanged, so existing fills and visual
baselines are unaffected.

Adds top/bottom/mid-band regression tests — partial-height placement was
previously untested because every factory helper uses heightRatio=1,
where top and bottom are indistinguishable.
@DemchaAV DemchaAV merged commit feeb665 into develop May 29, 2026
9 checks passed
@DemchaAV DemchaAV deleted the fix/pagebackgroundfill-y-coordinate branch May 29, 2026 09:06
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