Skip to content

Fix blank page after every region in region-day PDFs - #115

Open
anchovie91471 wants to merge 2 commits into
mainfrom
fix/region-day-blank-page
Open

Fix blank page after every region in region-day PDFs#115
anchovie91471 wants to merge 2 commits into
mainfrom
fix/region-day-blank-page

Conversation

@anchovie91471

@anchovie91471 anchovie91471 commented Aug 2, 2026

Copy link
Copy Markdown
Collaborator

Problem

In region-day with page breaks, large directories emit a blank page after
every region — a 204-page directory contained 96 blank pages.

Root cause

Controller::pdf() has two render paths, split at 500 meetings. At or below
500 it renders one document. Above 500 it renders each top-level group as its
own PDF and merges with FPDI — in region-day that is one region per chunk.

.region had page-break-after: always with no :last-child suppressor, so
every chunk ended with a trailing break and a blank page, all preserved by the
merge. day-region was unaffected because .day:last-child already existed.

Fix

Adds .region:last-child to the existing suppressor rule. Within each chunk the
lone region is :last-child, so the trailing break is suppressed.

Measured on a 60-region / 540-meeting feed: 120 pages (60 blank) → 60 pages
(0 blank).

Second commit: region-day rendered its heading unconditionally, so meetings
with no region produced an empty .heading — printing as a stray horizontal
rule above an untitled group. day-region already guards this; now both do.

Tests

Four regression tests, each verified to fail without its fix. The key addition
is chunked-path coverage: previously every test stayed under the 500-meeting
threshold and therefore exercised the wrong renderer, which is how this bug
was previously mis-scoped as a single trailing page.

.region got `page-break-after: always` in region-day mode, but the only
suppressor was `.day:last-child` -- there was no `.region:last-child`
counterpart. Mirrors the existing rule; `:last-child` (0,2,0) outranks
the bare `.region` (0,1,0), so source order is unaffected. The new
selector is inert in day-region mode, where .region never gets a break.

The impact is much larger than a single trailing page. Feeds over 500
meetings take the chunked path in Controller::pdf(): each top-level group
renders as its own standalone PDF and the results are merged with FPDI.
In region-day mode every chunk holds exactly one region, so pre-fix that
lone .region always emitted a trailing break -- producing a blank page at
the end of *every* chunk, all of which survive the merge. A 60-region
feed rendered 120 pages, 60 of them blank; with the fix it renders 60.
This is also why day-region was never affected: `.day:last-child` was
already doing this job for day chunks.

Adds three regression tests: the chunked path (60 regions, >500 meetings,
asserts one page per region -- fails at 120 pre-fix), plus the original
small-feed region-day case and a day-region control that passes either
way. The small-feed tests alone were insufficient: everything under 500
meetings takes a fast path that never exercises the merge.
region-day rendered `<span class="heading">{{ $region }}</span>`
unconditionally, so a feed containing meetings with no region produced an
empty heading for that group. The span carries `border-bottom: 0.5px
solid black`, so it printed as a stray horizontal rule above content with
no title -- visible as the untitled first group in large directories.

day-region already guards its label with `@if ($region)`, as does the
nested day subheading directly below. This mirrors that guard.

Adds a regression test rendering the template with a region-less group.
@anchovie91471
anchovie91471 force-pushed the fix/region-day-blank-page branch from bac2958 to 3ff0c34 Compare August 2, 2026 16:08
@anchovie91471 anchovie91471 changed the title Fix trailing blank page in region-day PDFs Fix blank page after every region in region-day PDFs Aug 2, 2026
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.

2 participants