parallax/jsPDF · error · Error
Invalid arguments passed to jsPDF.ellipse
Error message
Invalid arguments passed to jsPDF.ellipse
What it means
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').
Source
Thrown at src/jspdf.js:4880
* In "compat" API mode, a null value postpones setting the style so that a shape may be composed using multiple
* method calls. The last drawing method call used to define the shape should not have a null style argument.
*
* In "advanced" API mode this parameter is deprecated.
* @function
* @instance
* @returns {jsPDF}
* @memberof jsPDF#
* @name ellipse
*/
API.__private__.ellipse = API.ellipse = function(x, y, rx, ry, style) {
if (
isNaN(x) ||
isNaN(y) ||
isNaN(rx) ||
isNaN(ry) ||
!isValidStyle(style)
) {
throw new Error("Invalid arguments passed to jsPDF.ellipse");
}
var lx = (4 / 3) * (Math.SQRT2 - 1) * rx,
ly = (4 / 3) * (Math.SQRT2 - 1) * ry;
moveTo(x + rx, y);
curveTo(x + rx, y - ly, x + lx, y - ry, x, y - ry);
curveTo(x - lx, y - ry, x - rx, y - ly, x - rx, y);
curveTo(x - rx, y + ly, x - lx, y + ry, x, y + ry);
curveTo(x + lx, y + ry, x + rx, y + ly, x + rx, y);
putStyle(style);
return this;
};
/**
* Adds an circle to PDF.
*
* @param {number} x Coordinate (in units declared at inception of PDF document) against left edge of the pageView on GitHub (pinned to a3930ce03a)
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.
Example fix
// before pdf.ellipse(cx, cy, r, 'S'); // missing ry -> NaN // after pdf.ellipse(cx, cy, r, r, 'S');
Defensive patterns
Strategy: validation
Validate before calling
const VALID_STYLES = [undefined, null, 'S','D','F','DF','FD','f','f*','B','B*','n'];
function safeEllipse(doc, x, y, rx, ry, style) {
if (![x,y,rx,ry].every(Number.isFinite)) throw new Error('x,y,rx,ry must be finite');
return doc.ellipse(x, y, rx, ry, VALID_STYLES.includes(style) ? style : 'S');
} Type guard
function isValidStyle(s) { return [undefined,null,'S','D','F','DF','FD','f','f*','B','B*','n'].includes(s); } Prevention
- 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.
When it happens
Trigger: Calling ellipse() with an undefined radius, a negative/non-numeric rx or ry, or an unsupported style like 'stroke', 'fill', or a number.
Common situations: 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.
Related errors
- Invalid arguments passed to jsPDF.line
- Invalid arguments passed to jsPDF.lines
- Invalid arguments passed to jsPDF.rect
- Invalid arguments passed to jsPDF.triangle
- Invalid arguments passed to jsPDF.roundedRect
AI-assisted analysis of parallax/jsPDF@a3930ce03a (2026-08-13).
Data as JSON: /api/errors/2f6f6be75ba78b11.
Report an issue: GitHub.