Skip to content

Add a headerRows table option to repeat rows on new pages - #1849

Merged
blikblum merged 2 commits into
foliojs:masterfrom
kroplabeskidu:table-header-rows
Nov 1, 2026
Merged

blikblum merged 2 commits into
foliojs:masterfrom
kroplabeskidu:table-header-rows

Conversation

@kroplabeskidu

Copy link
Copy Markdown
Contributor

What kind of change does this PR introduce?

Feature. Fixes #1657

doc.table({ headerRows: 1, data });

The first rows are drawn again at the top of each new page, and the next row goes below them. If that row wouldn't fit below the header, the header is skipped on that page. In a structured table the repeated rows are marked as pagination artifacts, so they aren't added to the structure again.

Compared with similar APIs:

Library API
pdfmake headerRows: 1
ReportLab repeatRows=1
Prawn table(data, header: true)
jsPDF-AutoTable showHead: 'everyPage'

I used headerRows from pdfmake, since it is a JS library with the same data shape, and a count also covers several header rows.

I checked a 3 page table with pdf.js, with and without structParent: every page starts with the header and the next row sits below it.

A header at the very bottom of a page can still be left alone there, and a rowSpan reaching past the header rows isn't repeated.

Checklist:

  • Unit Tests
  • Documentation
  • Update CHANGELOG.md
  • Ready to be merged

@blikblum
blikblum merged commit 311b6c1 into foliojs:master Nov 1, 2026
3 checks passed
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.

Add table headers on each page

2 participants