Fix page overflow: add bounds checking and content splitting for multi-page songs #17
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Description
The PDF renderer (
PdfBookRenderer) has no bounds checking when placing content on pages. Theycoordinate decreases as content is added, but nothing prevents it from going below the bottom margin, causing text and images to render outside the visible page area.Additionally, 2-page songs currently render all content on page 0 and leave page 1 blank (see comment at
PdfBookRenderer.kt:160). There is no content splitting across pages.The measurement engine's height estimates are also approximate (line height =
1.2 × fontSize), so even songs classified as 1-page may overflow if the estimate diverges from actual rendering.Root Causes
renderSongPage()never checks ifyhas gone below the bottom marginPdfFontMetricsestimates may diverge from actual rendered sizesAcceptance Criteria
yposition against the bottom margin during song page renderingImplementation Hints
PdfBookRenderer.renderSongPage(), trackyand compare against ayMin(bottom margin + reserved footer space)ywould drop belowyMinon page 0 of a 2-page song, stop rendering on page 0 and continue remaining sections on page 1