parallax/jsPDF · error · Error
Invalid arguments passed to jsPDF.circle
Error message
Invalid arguments passed to jsPDF.circle
What it means
Thrown by jsPDF.circle when x, y, or r is NaN or the style is invalid. All three must be finite numbers; style must pass isValidStyle (undefined, null, 'S', 'D', 'F', 'DF', 'FD', 'f', 'f*', 'B', 'B*', 'n'). circle delegates to ellipse with rx=ry=r.
Source
Thrown at src/jspdf.js:4917
* @param {number} y Coordinate (in units declared at inception of PDF document) against upper edge of the page
* @param {number} r Radius (in units declared at inception of PDF document)
* @param {string=} style A string specifying the painting style or null. Valid styles include:
* 'S' [default] - stroke,
* 'F' - fill,
* and 'DF' (or 'FD') - fill then stroke.
* 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 circle
*/
API.__private__.circle = API.circle = function(x, y, r, style) {
if (isNaN(x) || isNaN(y) || isNaN(r) || !isValidStyle(style)) {
throw new Error("Invalid arguments passed to jsPDF.circle");
}
return this.ellipse(x, y, r, r, style);
};
/**
* Sets text font face, variant for upcoming text elements.
* See output of jsPDF.getFontList() for possible font names, styles.
*
* @param {string} fontName Font name or family. Example: "times".
* @param {string} fontStyle Font style or variant. Example: "italic".
* @param {number | string} fontWeight Weight of the Font. Example: "normal" | 400
* @function
* @instance
* @returns {jsPDF}
* @memberof jsPDF#
* @name setFont
*/
API.setFont = function(fontName, fontStyle, fontWeight) {View on GitHub (pinned to a3930ce03a)
Solutions
- Pass finite numeric x, y, r and a supported style code.
- Use 'S' to stroke, 'F' to fill, 'DF' for both, or null/undefined.
- Coerce the radius with Number() and guard against NaN.
Example fix
// before pdf.circle(cx, cy, d, 'stroke'); // d may be undefined; 'stroke' invalid // after pdf.circle(cx, cy, Number(d) || 0, 'S');
Defensive patterns
Strategy: validation
Validate before calling
const VALID_STYLES = [undefined, null, 'S','D','F','DF','FD','f','f*','B','B*','n'];
function safeCircle(doc, x, y, r, style) {
if (![x,y,r].every(Number.isFinite)) throw new Error('x,y,r must be finite');
return doc.circle(x, y, r, 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
- Ensure the radius is a finite number (pass radius, not diameter, unless intended).
- Use 'S'/'F'/'DF' for style.
- Default missing radius to 0 explicitly.
When it happens
Trigger: Calling circle() with an undefined radius, a non-numeric coordinate, or an unsupported style such as 'stroke', 'fill', or a number.
Common situations: Radius derived from missing data; friendly style names used instead of PDF operator codes; passing a diameter as the radius without numeric coercion.
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/f267a03e521740c3.
Report an issue: GitHub.