Skip to content

fix footer/header behaviour - #549

Open
splitbrain wants to merge 1 commit into
masterfrom
header-footer-named
Open

fix footer/header behaviour#549
splitbrain wants to merge 1 commit into
masterfrom
header-footer-named

Conversation

@splitbrain

Copy link
Copy Markdown
Owner

I had switched to runtime setting of headers and footers to be able to dynamically set the context when multiple pages are exported (eg. have the header reflect the currently rendered wiki page). But that had issues, especially for the first page template.

This switches to mPDF's named headers. The named headers are assigned via CSS just as before, but are now dynamically redefined on every new page.

@Klap-in can you check if this solves issue #548?

The first-page header and footer were set with runtime SetHTMLHeader and
SetHTMLFooter calls that were not bound to a specific page, so they spread
beyond the first physical page onto the rest of the first content block and,
for the header, even onto the following content while leaving the very first
page without a header.

They are now defined as named blocks bound through @page CSS rules: @page :first
restricts the first-page block to the first physical page, while the odd and even
blocks cover the remaining pages. Those blocks are redefined before each wiki
page so their per-page placeholders (@id@, @pageurl@, @qrcode@, ...) resolve
against the current page, and the first-page context is set before the document
starts so the blocks defined at start-up resolve too.

Fixes #548
@splitbrain
splitbrain requested a review from Klap-in July 24, 2026 20:18
@Klap-in

Klap-in commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

Works fine (now tested for single page only) for the following combinations, with ToC enabled:

  • no cover, no header&footer
  • no cover, header&footer
  • no cover, header&footer and first header&footer - first page is not first page of pdf, but first ToC and a blank page are shown with a normal header&footer, next on the first page of the article the first header&footer is once shown.
  • no cover, even/odd header&footer
  • no cover, even/odd header&footer and first header&footer - first page is not first page of pdf, but first ToC and a blank page are shown with a even/odd header&footer, next on the first page of the article the first header&footer is once shown.
  • with cover, no header&footer
  • with cover, header&footer
  • with cover, header&footer and first header&footer
  • with cover, even/odd header&footer
  • with cover, even/odd header&footer and first header&footer

However, the two deviations happened before the refactoring as well. Probably this is quirk of mPdf. I guess because the ToC generation happens later, and :first is applied to the actual first page that is generated.

@Klap-in

Klap-in commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

So it seems the header/footer for first page works only correctly when a cover page is used... likely, that is the most used application for the first page footer/header.

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