{"record":{"id":"75854bbf19800cdd","repo":"parallax/jsPDF","slug":"invalid-argument-passed-to-jspdf-setlinemiterlimit","errorCode":null,"errorMessage":"Invalid argument passed to jsPDF.setLineMiterLimit","messagePattern":"Invalid argument passed to jsPDF\\.setLineMiterLimit","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/jspdf.js","lineNumber":5511,"sourceCode":"  };\n\n  var miterLimit;\n  /**\n   * Sets the miterLimit property, which effects the maximum miter length.\n   *\n   * @param {number} length The length of the miter\n   * @function\n   * @instance\n   * @returns {jsPDF}\n   * @memberof jsPDF#\n   * @name setLineMiterLimit\n   */\n  API.__private__.setLineMiterLimit = API.__private__.setMiterLimit = API.setLineMiterLimit = API.setMiterLimit = function(\n    length\n  ) {\n    length = length || 0;\n    if (isNaN(length)) {\n      throw new Error(\"Invalid argument passed to jsPDF.setLineMiterLimit\");\n    }\n    out(hpf(scale(length)) + \" M\");\n\n    return this;\n  };\n\n  /**\n   * An object representing a pdf graphics state.\n   * @class GState\n   */\n\n  /**\n   *\n   * @param parameters A parameter object that contains all properties this graphics state wants to set.\n   * Supported are: opacity, stroke-opacity\n   * @constructor\n   */\n  API.GState = GState;","sourceCodeStart":5493,"sourceCodeEnd":5529,"githubUrl":"https://github.com/parallax/jsPDF/blob/a3930ce03a585a26b2c76d12a0f413ce96f6d1a3/src/jspdf.js#L5493-L5529","documentation":"Thrown by setLineMiterLimit (alias setMiterLimit) when the length argument is NaN after the isNaN() check. Note the line `length = length || 0` converts falsy values (0, null, '', undefined) to 0 before the NaN test, so this error only fires when length is a non-numeric truthy value (e.g. a string like 'abc', an object, or an actual NaN produced by arithmetic). The value is then scaled and emitted as the PDF 'M' operator.","triggerScenarios":"Calling doc.setLineMiterLimit('abc'), doc.setLineMiterLimit(NaN) where NaN is truthy-impossible (NaN is falsy... actually NaN is falsy so length||0 makes it 0, so NaN never reaches the throw). Calling with an object, array, or non-empty non-numeric string that survives the || 0 coercion. Arithmetic that yields a non-numeric truthy value.","commonSituations":"Reading miter limit from an unvalidated text input; passing a unit-string like '5px' instead of a number; chaining calculations where an intermediate produced a truthy non-number.","solutions":["Pass a plain number, e.g. doc.setLineMiterLimit(5).","Coerce explicitly before calling: doc.setLineMiterLimit(Number(value)) and guard with !isNaN.","If value may be a CSS unit string, strip the unit and parse float first."],"exampleFix":"// before\ndoc.setLineMiterLimit(input.value); // input.value === '5px'\n// after\nvar v = parseFloat(input.value);\ndoc.setLineMiterLimit(isNaN(v) ? 0 : v);","handlingStrategy":"validation","validationCode":"var n = Number(value);\nif (!isNaN(n)) doc.setLineMiterLimit(n);","typeGuard":"function isFiniteNumber(v){ return typeof v === 'number' && isFinite(v); }","tryCatchPattern":"try { doc.setLineMiterLimit(value); } catch (e) { if (/setLineMiterLimit/.test(e.message)) doc.setLineMiterLimit(0); else throw e; }","preventionTips":["Always parseFloat user input","Never pass CSS unit strings to numeric PDF APIs"],"tags":["jspdf","validation","numeric","argument"],"backgroundTag":null,"analyzedSha":"a3930ce03a585a26b2c76d12a0f413ce96f6d1a3","analyzedAt":"2026-08-13T05:33:39.648Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}