From f514a11e6ae2dc7477d25e69de1de079ff59e78d Mon Sep 17 00:00:00 2001 From: Libor M Date: Sat, 30 Dec 2023 15:41:15 +0100 Subject: [PATCH] Fixed "Cannot read properties of undefined (reading 'bottomMost')" if table contains too few rows #2549 --- CHANGELOG.md | 1 + src/TableProcessor.js | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9161b94de..5ff436cad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - Minimal supported version Node.js 16 LTS - Fixed cover image size inside table +- Fixed "Cannot read properties of undefined (reading 'bottomMost')" if table contains too few rows ## 0.3.0-beta.6 - 2023-11-09 diff --git a/src/TableProcessor.js b/src/TableProcessor.js index f09dff521..a201f3618 100644 --- a/src/TableProcessor.js +++ b/src/TableProcessor.js @@ -102,6 +102,10 @@ class TableProcessor { this.cleanUpRepeatables = false; this.headerRows = tableNode.table.headerRows || 0; + if (this.headerRows > tableNode.table.body.length) { + throw new Error(`Too few rows in the table. Property headerRows requires at least ${this.headerRows}, contains only ${tableNode.table.body.length}`); + } + this.rowsWithoutPageBreak = this.headerRows + (tableNode.table.keepWithHeaderRows || 0); this.dontBreakRows = tableNode.table.dontBreakRows || false;