parallax/jsPDF · error · Error
Property tableHeaderRow does not exist.
Error message
Property tableHeaderRow does not exist.
What it means
printHeaderRow() outputs a previously stored header row configuration on subsequent pages of a multi-page table. It reads from this.internal.__cell__.tableHeaderRow, which is set by setTableHeaderRow() or automatically by the table() function. Calling printHeaderRow without first defining a header row means there is no configuration to render, so the function throws rather than silently producing an empty or broken layout.
Source
Thrown at src/modules/cell.js:636
* except the lineNumber parameter is excluded
*/
jsPDFAPI.setTableHeaderRow = function(config) {
_initialize.call(this);
this.internal.__cell__.tableHeaderRow = config;
};
/**
* Output the store header row
*
* @name printHeaderRow
* @function
* @param {number} lineNumber The line number to output the header at
* @param {boolean} new_page
*/
jsPDFAPI.printHeaderRow = function(lineNumber, new_page) {
_initialize.call(this);
if (!this.internal.__cell__.tableHeaderRow) {
throw new Error("Property tableHeaderRow does not exist.");
}
var tableHeaderCell;
printingHeaderRow = true;
if (typeof this.internal.__cell__.headerFunction === "function") {
var position = this.internal.__cell__.headerFunction(
this,
this.internal.__cell__.pages
);
this.internal.__cell__.lastCell = new Cell(
position[0],
position[1],
position[2],
position[3],
undefined,
-1
);View on GitHub (pinned to a3930ce03a)
Solutions
- Call doc.setTableHeaderRow(headerConfig) before calling printHeaderRow
- Ensure doc.table() has been called at least once, which sets up the header row automatically
- Check for the property before calling: if (doc.internal.__cell__?.tableHeaderRow) doc.printHeaderRow(lineNumber)
- In page-break callbacks, verify the header row exists before reprinting
Example fix
// before doc.printHeaderRow(1); // throws - no header set // after - set header row first doc.setTableHeaderRow(headerCells); doc.printHeaderRow(1); // or ensure table() ran first doc.table(10, 10, data, headers); // ... on new page: doc.printHeaderRow(currentLineNumber, true);
Defensive patterns
Strategy: validation
Validate before calling
// Check for tableHeaderRow before calling printHeaderRow
function safePrintHeaderRow(doc, lineNumber, newPage) {
var cellState = doc.internal.__cell__;
if (cellState && cellState.tableHeaderRow) {
doc.printHeaderRow(lineNumber, newPage);
} else {
console.warn('tableHeaderRow not set - call setTableHeaderRow or table() first');
}
} Type guard
/**
* @param {jsPDF} doc
* @returns {boolean}
*/
function hasTableHeaderRow(doc) {
return !!(doc.internal.__cell__ && doc.internal.__cell__.tableHeaderRow);
} Try / catch
try {
doc.printHeaderRow(lineNumber, true);
} catch (e) {
if (e.message.includes('tableHeaderRow does not exist')) {
// Header not set yet - skip or set it
doc.setTableHeaderRow(headerConfig);
doc.printHeaderRow(lineNumber, true);
} else throw e;
} Prevention
- Call doc.table() or doc.setTableHeaderRow() before any printHeaderRow call
- In page-break callbacks, check doc.internal.__cell__.tableHeaderRow exists
- Use the table() API which manages header rows automatically for multi-page tables
When it happens
Trigger: Calling doc.printHeaderRow(1) without first calling doc.table() or doc.setTableHeaderRow(). Calling printHeaderRow after a page break in custom table logic where setTableHeaderRow was not invoked. Using printHeaderRow in a total_pages/addPage callback before any table() call established the header.
Common situations: Custom multi-page table implementations that manually manage page breaks. Using printHeaderRow in the 'addPage' event handler without ensuring table() ran first. Mixing the old cell-based API with the table() API incorrectly. Calling printHeaderRow after resetting internal state.
Related errors
AI-assisted analysis of parallax/jsPDF@a3930ce03a (2026-08-13).
Data as JSON: /api/errors/04d1504a6b056af0.
Report an issue: GitHub.