{"record":{"id":"04d1504a6b056af0","repo":"parallax/jsPDF","slug":"property-tableheaderrow-does-not-exist","errorCode":null,"errorMessage":"Property tableHeaderRow does not exist.","messagePattern":"Property tableHeaderRow does not exist\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/modules/cell.js","lineNumber":636,"sourceCode":"   * except the lineNumber parameter is excluded\n   */\n  jsPDFAPI.setTableHeaderRow = function(config) {\n    _initialize.call(this);\n    this.internal.__cell__.tableHeaderRow = config;\n  };\n\n  /**\n   * Output the store header row\n   *\n   * @name printHeaderRow\n   * @function\n   * @param {number} lineNumber The line number to output the header at\n   * @param {boolean} new_page\n   */\n  jsPDFAPI.printHeaderRow = function(lineNumber, new_page) {\n    _initialize.call(this);\n    if (!this.internal.__cell__.tableHeaderRow) {\n      throw new Error(\"Property tableHeaderRow does not exist.\");\n    }\n\n    var tableHeaderCell;\n\n    printingHeaderRow = true;\n    if (typeof this.internal.__cell__.headerFunction === \"function\") {\n      var position = this.internal.__cell__.headerFunction(\n        this,\n        this.internal.__cell__.pages\n      );\n      this.internal.__cell__.lastCell = new Cell(\n        position[0],\n        position[1],\n        position[2],\n        position[3],\n        undefined,\n        -1\n      );","sourceCodeStart":618,"sourceCodeEnd":654,"githubUrl":"https://github.com/parallax/jsPDF/blob/a3930ce03a585a26b2c76d12a0f413ce96f6d1a3/src/modules/cell.js#L618-L654","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\ndoc.printHeaderRow(1); // throws - no header set\n\n// after - set header row first\ndoc.setTableHeaderRow(headerCells);\ndoc.printHeaderRow(1);\n// or ensure table() ran first\ndoc.table(10, 10, data, headers);\n// ... on new page:\ndoc.printHeaderRow(currentLineNumber, true);","handlingStrategy":"validation","validationCode":"// Check for tableHeaderRow before calling printHeaderRow\nfunction safePrintHeaderRow(doc, lineNumber, newPage) {\n  var cellState = doc.internal.__cell__;\n  if (cellState && cellState.tableHeaderRow) {\n    doc.printHeaderRow(lineNumber, newPage);\n  } else {\n    console.warn('tableHeaderRow not set - call setTableHeaderRow or table() first');\n  }\n}","typeGuard":"/**\n * @param {jsPDF} doc\n * @returns {boolean}\n */\nfunction hasTableHeaderRow(doc) {\n  return !!(doc.internal.__cell__ && doc.internal.__cell__.tableHeaderRow);\n}","tryCatchPattern":"try {\n  doc.printHeaderRow(lineNumber, true);\n} catch (e) {\n  if (e.message.includes('tableHeaderRow does not exist')) {\n    // Header not set yet - skip or set it\n    doc.setTableHeaderRow(headerConfig);\n    doc.printHeaderRow(lineNumber, true);\n  } else throw e;\n}","preventionTips":["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"],"tags":["cell","table","header-row","state-check"],"backgroundTag":null,"analyzedSha":"a3930ce03a585a26b2c76d12a0f413ce96f6d1a3","analyzedAt":"2026-08-13T05:33:39.648Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}