{"record":{"id":"c2f6a321df7d3b6b","repo":"parallax/jsPDF","slug":"invalid-argument-passed-to-jspdf-getdocumentproper","errorCode":null,"errorMessage":"Invalid argument passed to jsPDF.getDocumentProperty","messagePattern":"Invalid argument passed to jsPDF\\.getDocumentProperty","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/jspdf.js","lineNumber":1013,"sourceCode":"    pmode\n  ) {\n    setZoomMode(zoom);\n    setLayoutMode(layout);\n    setPageMode(pmode);\n    return this;\n  };\n\n  var documentProperties = {\n    title: \"\",\n    subject: \"\",\n    author: \"\",\n    keywords: \"\",\n    creator: \"\"\n  };\n\n  API.__private__.getDocumentProperty = function(key) {\n    if (Object.keys(documentProperties).indexOf(key) === -1) {\n      throw new Error(\"Invalid argument passed to jsPDF.getDocumentProperty\");\n    }\n    return documentProperties[key];\n  };\n\n  API.__private__.getDocumentProperties = function() {\n    return documentProperties;\n  };\n\n  /**\n   * Adds a properties to the PDF document.\n   *\n   * @param {Object} A property_name-to-property_value object structure.\n   * @function\n   * @instance\n   * @returns {jsPDF}\n   * @memberof jsPDF#\n   * @name setDocumentProperties\n   */","sourceCodeStart":995,"sourceCodeEnd":1031,"githubUrl":"https://github.com/parallax/jsPDF/blob/a3930ce03a585a26b2c76d12a0f413ce96f6d1a3/src/jspdf.js#L995-L1031","documentation":"`getDocumentProperty` (src/jspdf.js:1007) reads one of the five built-in metadata fields: `title`, `subject`, `author`, `keywords`, `creator`. It throws at src/jspdf.js:1012 if the requested key isn't in that set — jsPDF only models those standard Info-dictionary properties, not arbitrary custom keys.","triggerScenarios":"`doc.internal.__private__.getDocumentProperty('producer')` (not a stored key); `'creationDate'` (handled separately via getCreationDate); `'custom_field'`; a typo like `'tittle'`.","commonSituations":"Treating getDocumentProperty as a generic key-value store; confusing it with getCreationDate/getFileId which are separate APIs; typos in property names from dynamic access.","solutions":["Use only the five allowed keys: title, subject, author, keywords, creator.","For dates use `doc.getCreationDate()`; for the file id use `doc.internal.getFileId()`.","If you need custom metadata, note jsPDF doesn't store arbitrary keys — extend via a plugin or store outside the Info dict."],"exampleFix":"// before\n doc.internal.__private__.getDocumentProperty('producer');  // throws\n\n// after\n // 'producer' isn't user-settable via this API; use a stored key:\n doc.internal.__private__.getDocumentProperty('creator');","handlingStrategy":"validation","validationCode":"var PROP_KEYS = ['title','subject','author','keywords','creator'];\nfunction getProp(doc, key) {\n  if (PROP_KEYS.indexOf(key) === -1) return undefined;\n  return doc.internal.__private__.getDocumentProperty(key);\n}","typeGuard":"function isDocumentPropertyKey(k) {\n  return ['title','subject','author','keywords','creator'].indexOf(k) !== -1;\n}","tryCatchPattern":"try {\n  val = doc.internal.__private__.getDocumentProperty(key);\n} catch (e) {\n  if (/getDocumentProperty/.test(e.message)) {\n    val = undefined;  // unknown key -> no value\n  } else throw e;\n}","preventionTips":["Restrict keys to the five standard metadata fields.","Use doc.getCreationDate()/getFileId() for those specific values.","Don't treat getDocumentProperty as a generic store."],"tags":["metadata","properties","validation"],"backgroundTag":null,"analyzedSha":"a3930ce03a585a26b2c76d12a0f413ce96f6d1a3","analyzedAt":"2026-08-13T05:33:39.648Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}