Skip to content

Fix extra blank page when using headerRows + dontBreakRows + cell pageBreak #2929

Merged
liborm85 merged 6 commits intobpampuch:masterfrom
NadeemShadan:issue-2730-table-pagebreak-headerrows
Mar 29, 2026
Merged

Fix extra blank page when using headerRows + dontBreakRows + cell pageBreak #2929
liborm85 merged 6 commits intobpampuch:masterfrom
NadeemShadan:issue-2730-table-pagebreak-headerrows

Conversation

@NadeemShadan
Copy link
Copy Markdown
Contributor

fixes #2730
Updated TableProcessor::beginRow/endRow to skip per-row unbreakable wrapping when a row contains an explicit cell pageBreak, preventing the extra blank page with headerRows + dontBreakRows.

added integration coverage in tests/integration/tables.spec.js to verify the #2730 scenario does not create an extra page.

  • npm test
  • npx mocha --reporter spec tests/integration/tables.spec.js

@liborm85
Copy link
Copy Markdown
Collaborator

Run build examples npm run build:examples, it returns errors.

@NadeemShadan
Copy link
Copy Markdown
Contributor Author

Libor,

Thanks for checking this.

I re-ran build:examples on my branch and can’t reproduce a failure.

Environment:

  • branch: issue-2730-table-pagebreak-headerrows
  • commit: 7f49fc9
  • Node: v20.19.6
  • npm: 10.8.2

Command:

  • npm run build:examples

Result:

  • exit code 0
  • all example files processed (31/31)
  • no stderr/errors

I also verified on Node v22.9.0 (npm 10.8.3) with the same passing result.

Could you share your exact Node/npm versions and the full npm run build:examples output so I can reproduce your environment?

@liborm85 liborm85 force-pushed the issue-2730-table-pagebreak-headerrows branch from 52fb077 to 3adc881 Compare March 28, 2026 13:38
@liborm85
Copy link
Copy Markdown
Collaborator

Added npm run build:examples to ci and all node versions failed, see https://github.com/bpampuch/pdfmake/actions/runs/23686397207/job/69006503323?pr=2929 output is:

FILE:  verticalAlignment.js  (12/31)

Error: unsupported number: NaN
    at number (/home/runner/work/pdfmake/pdfmake/node_modules/pdfkit/js/pdfkit.js:162:11)
    at /home/runner/work/pdfmake/pdfmake/node_modules/pdfkit/js/pdfkit.js:2152:58
    at Array.map (<anonymous>)
    at PDFDocument.transform (/home/runner/work/pdfmake/pdfmake/node_modules/pdfkit/js/pdfkit.js:2152:49)
    at PDFDocument.addPage (/home/runner/work/pdfmake/pdfmake/node_modules/pdfkit/js/pdfkit.js:6090:10)
    at Renderer.renderPages (/home/runner/work/pdfmake/pdfmake/js/Renderer.js:58:24)
    at PdfPrinter.createPdfKitDocument (/home/runner/work/pdfmake/pdfmake/js/Printer.js:93:14)
    at async OutputDocumentServer.write (/home/runner/work/pdfmake/pdfmake/js/OutputDocumentServer.js:14:20)

@NadeemShadan
Copy link
Copy Markdown
Contributor Author

I found the CI failure root cause and pushed a fix.

Root cause:

  • My previous change altered dontBreakRows row unbreakable handling.
  • For rows with explicit pageBreak, row-level unbreakable is intentionally skipped.
  • But row 0 also stopped committing the unbreakable block, which left the unbreakable context open.
  • That leaked invalid page metadata and produced pageSize.height = NaN, which later crashed in PDFKit (unsupported number: NaN during addPage).

Fix:

  • In src/TableProcessor.js, I now commit for:
    • dontBreakRows && rowIndex === 0 (required to close the initial table unbreakable block), or
    • dontBreakRows && _isCurrentRowUnbreakable (normal row-level case).

Validation:

  • npm run build:examples now passes (including verticalAlignment.js and toc.js).
  • Added regression test in tests/integration/tables.spec.js:
  • `keeps finite page dimensions with dontBreakRows tables without headers`
    
  • Existing regression test for issue Page break within a table component #2730 still passes.
    • npm test passes.

@liborm85 liborm85 merged commit 40d74b2 into bpampuch:master Mar 29, 2026
10 checks passed
@liborm85
Copy link
Copy Markdown
Collaborator

Merged. Thanks.

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.

Page break within a table component

2 participants