{"record":{"id":"2f6f6be75ba78b11","repo":"parallax/jsPDF","slug":"invalid-arguments-passed-to-jspdf-ellipse","errorCode":null,"errorMessage":"Invalid arguments passed to jsPDF.ellipse","messagePattern":"Invalid arguments passed to jsPDF\\.ellipse","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/jspdf.js","lineNumber":4880,"sourceCode":"   * In \"compat\" API mode, a null value postpones setting the style so that a shape may be composed using multiple\n   * method calls. The last drawing method call used to define the shape should not have a null style argument.\n   *\n   * In \"advanced\" API mode this parameter is deprecated.\n   * @function\n   * @instance\n   * @returns {jsPDF}\n   * @memberof jsPDF#\n   * @name ellipse\n   */\n  API.__private__.ellipse = API.ellipse = function(x, y, rx, ry, style) {\n    if (\n      isNaN(x) ||\n      isNaN(y) ||\n      isNaN(rx) ||\n      isNaN(ry) ||\n      !isValidStyle(style)\n    ) {\n      throw new Error(\"Invalid arguments passed to jsPDF.ellipse\");\n    }\n    var lx = (4 / 3) * (Math.SQRT2 - 1) * rx,\n      ly = (4 / 3) * (Math.SQRT2 - 1) * ry;\n\n    moveTo(x + rx, y);\n    curveTo(x + rx, y - ly, x + lx, y - ry, x, y - ry);\n    curveTo(x - lx, y - ry, x - rx, y - ly, x - rx, y);\n    curveTo(x - rx, y + ly, x - lx, y + ry, x, y + ry);\n    curveTo(x + lx, y + ry, x + rx, y + ly, x + rx, y);\n\n    putStyle(style);\n    return this;\n  };\n\n  /**\n   * Adds an circle to PDF.\n   *\n   * @param {number} x Coordinate (in units declared at inception of PDF document) against left edge of the page","sourceCodeStart":4862,"sourceCodeEnd":4898,"githubUrl":"https://github.com/parallax/jsPDF/blob/a3930ce03a585a26b2c76d12a0f413ce96f6d1a3/src/jspdf.js#L4862-L4898","documentation":"Thrown by jsPDF.ellipse when x, y, rx, or ry is NaN or the style is invalid. All four must be finite numbers; style must pass isValidStyle (undefined, null, 'S', 'D', 'F', 'DF', 'FD', 'f', 'f*', 'B', 'B*', 'n').","triggerScenarios":"Calling ellipse() with an undefined radius, a negative/non-numeric rx or ry, or an unsupported style like 'stroke', 'fill', or a number.","commonSituations":"Radii sourced from optional config; friendly style names instead of PDF codes; passing a diameter where a radius is expected without ensuring it is numeric.","solutions":["Pass finite numeric x, y, rx, ry and a supported style code.","Map 'stroke'/'fill' to 'S'/'F'.","Default or coerce radii to numbers before calling."],"exampleFix":"// before\npdf.ellipse(cx, cy, r, 'S'); // missing ry -> NaN\n// after\npdf.ellipse(cx, cy, r, r, 'S');","handlingStrategy":"validation","validationCode":"const VALID_STYLES = [undefined, null, 'S','D','F','DF','FD','f','f*','B','B*','n'];\nfunction safeEllipse(doc, x, y, rx, ry, style) {\n  if (![x,y,rx,ry].every(Number.isFinite)) throw new Error('x,y,rx,ry must be finite');\n  return doc.ellipse(x, y, rx, ry, VALID_STYLES.includes(style) ? style : 'S');\n}","typeGuard":"function isValidStyle(s) { return [undefined,null,'S','D','F','DF','FD','f','f*','B','B*','n'].includes(s); }","tryCatchPattern":null,"preventionTips":["Pass both rx and ry (use the same value for a circle-like ellipse).","Coerce radii with Number() and guard NaN.","Use PDF operator codes for style."],"tags":["validation","shapes","ellipse","style","api"],"backgroundTag":null,"analyzedSha":"a3930ce03a585a26b2c76d12a0f413ce96f6d1a3","analyzedAt":"2026-08-13T05:33:39.648Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}