Fix blank pages between TOC and first song #33
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?
Problem
Empty/blank pages appear between the table of contents and the first song (e.g. pages 9-12 are blank).
Root Cause
Two bugs in TOC page allocation:
TocGenerator.estimateTocPages()uses a rough estimate of 40 entries per A5 page. With ~296 songs this estimates 10 TOC pages, but the actual rendered TOC may only need 8.PdfBookRendererblindly addstocPages - 1blank pages after the TOC table renders, regardless of how many pages the table already consumed. Since OpenPDF'sPdfPTableauto-paginates across multiple pages, the TOC table itself already uses several pages. The padding logic then adds additional blank pages on top, resulting in far more TOC pages than allocated.Fix
measurePages()toTocRendererthat pre-renders the TOC to a temporary document and counts actual pages needed (rounded to even for double-sided printing).SongbookPipelineto use the measured page count instead of the rough estimate, and re-generate TOC entries with corrected page numbers.PdfBookRendererpadding logic to usewriter.pageNumberafter TOC rendering, only adding blank pages to reach the allocated count (not blindly addingtocPages - 1).Acceptance Criteria