{"record":{"id":"e39fd21dd8ce182c","repo":"parallax/jsPDF","slug":"line-cap-style-of-style-is-not-recognized-see","errorCode":null,"errorMessage":"Line cap style of '{style}' is not recognized. See or extend .CapJoinStyles property for valid styles","messagePattern":"Line cap style of '(.+?)' is not recognized\\. See or extend \\.CapJoinStyles property for valid styles","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/jspdf.js","lineNumber":5456,"sourceCode":"    square: 2,\n    bevel: 2\n  };\n\n  /**\n   * Sets the line cap styles.\n   * See {jsPDF.CapJoinStyles} for variants.\n   *\n   * @param {String|Number} style A string or number identifying the type of line cap.\n   * @function\n   * @instance\n   * @returns {jsPDF}\n   * @memberof jsPDF#\n   * @name setLineCap\n   */\n  API.__private__.setLineCap = API.setLineCap = function(style) {\n    var id = API.CapJoinStyles[style];\n    if (id === undefined) {\n      throw new Error(\n        \"Line cap style of '\" +\n          style +\n          \"' is not recognized. See or extend .CapJoinStyles property for valid styles\"\n      );\n    }\n    lineCapID = id;\n    out(id + \" J\");\n\n    return this;\n  };\n\n  var lineJoinID = 0;\n  /**\n   * Sets the line join styles.\n   * See {jsPDF.CapJoinStyles} for variants.\n   *\n   * @param {String|Number} style A string or number identifying the type of line join.\n   * @function","sourceCodeStart":5438,"sourceCodeEnd":5474,"githubUrl":"https://github.com/parallax/jsPDF/blob/a3930ce03a585a26b2c76d12a0f413ce96f6d1a3/src/jspdf.js#L5438-L5474","documentation":"Thrown by jsPDF.setLineCap when the style is not a key in jsPDF.CapJoinStyles. Valid keys are: 0, 'butt', 'but', 'miter' (all map to 0); 1, 'round', 'rounded', 'circle' (map to 1); 2, 'projecting', 'project' (map to 2). Any other string or number is unrecognized. Note CapJoinStyles is shared between line cap and line join, so join-specific names like 'miter' are accepted here too.","triggerScenarios":"Calling setLineCap('square') (CSS line-cap value, unsupported), setLineCap('butt '), setLineCap(3), or setLineCap(undefined) — undefined is not a key, so it throws.","commonSituations":"Mapping CSS `stroke-linecap` values ('butt', 'round', 'square') directly; note 'square' has no jsPDF equivalent (use 'projecting' for a projecting cap); casing or whitespace mistakes; passing a numeric value outside 0-2.","solutions":["Use one of: 0/'butt', 1/'round', or 2/'projecting'.","Map CSS 'square' to 'projecting' (code 2) in your wrapper, or omit it.","Trim and validate the style against Object.keys(doc.CapJoinStyles) before calling."],"exampleFix":"// before\npdf.setLineCap('square'); // not in CapJoinStyles\n// after\npdf.setLineCap('projecting'); // code 2","handlingStrategy":"validation","validationCode":"function safeSetLineCap(doc, style) {\n  const valid = new Set(Object.keys(doc.CapJoinStyles));\n  const key = typeof style === 'string' ? style.trim().toLowerCase() : style;\n  if (!valid.has(key) && !valid.has(String(key))) throw new Error('unsupported line cap: ' + style);\n  return doc.setLineCap(key);\n}","typeGuard":"function isValidLineCap(doc, s) { return Object.prototype.hasOwnProperty.call(doc.CapJoinStyles, s); }","tryCatchPattern":null,"preventionTips":["Use 0/'butt', 1/'round', or 2/'projecting'.","Map CSS 'square' to 'projecting' (2) since jsPDF has no 'square'.","Validate against Object.keys(doc.CapJoinStyles) at the boundary."],"tags":["validation","line-cap","cap-join-styles","api"],"backgroundTag":null,"analyzedSha":"a3930ce03a585a26b2c76d12a0f413ce96f6d1a3","analyzedAt":"2026-08-13T05:33:39.648Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}