parallax/jsPDF · error · Error
arcTo not implemented.
Error message
arcTo not implemented.
What it means
The Canvas2D-compatible context2d API exposed by jsPDF (obtained via doc.context2d) implements most of the HTML5 Canvas drawing surface, but arcTo() is an explicit stub: the body is a single unconditional throw. The jsdoc promises arc/curve-between-tangents behavior that was never ported to the PDF path model. Calling it always fails, regardless of arguments.
Source
Thrown at src/modules/context2d.js:1036
});
// this.ctx.lastPoint(new Point(pt.x,pt.y));
};
/**
* Creates an arc/curve between two tangents
*
* @name arcTo
* @function
* @param x1 {Number} The x-coordinate of the first tangent
* @param y1 {Number} The y-coordinate of the first tangent
* @param x2 {Number} The x-coordinate of the second tangent
* @param y2 {Number} The y-coordinate of the second tangent
* @param radius The radius of the arc
* @description The arcTo() method creates an arc/curve between two tangents on the canvas.
*/
// eslint-disable-next-line no-unused-vars
Context2D.prototype.arcTo = function(x1, y1, x2, y2, radius) {
throw new Error("arcTo not implemented.");
};
/**
* Creates a rectangle
*
* @name rect
* @function
* @param x {Number} The x-coordinate of the upper-left corner of the rectangle
* @param y {Number} The y-coordinate of the upper-left corner of the rectangle
* @param w {Number} The width of the rectangle, in pixels
* @param h {Number} The height of the rectangle, in pixels
* @description The rect() method creates a rectangle.
*/
Context2D.prototype.rect = function(x, y, w, h) {
if (isNaN(x) || isNaN(y) || isNaN(w) || isNaN(h)) {
console.error("jsPDF.context2d.rect: Invalid arguments", arguments);
throw new Error("Invalid arguments passed to jsPDF.context2d.rect");
}View on GitHub (pinned to a3930ce03a)
Solutions
- Replace arcTo with an equivalent built from lineTo plus arc() (which IS implemented): compute the tangent intersection and draw a quadratic/circular arc segment manually.
- Draw rounded rectangles via a path of lineTo/arc/quadraticCurveTo calls instead of arcTo.
- Render the shape to an offscreen HTML <canvas> first, then embed it as an image via doc.addImage (the canvas2d arcTo restriction then does not apply).
- Avoid the context2d surface entirely and draw the rounded path with jsPDF's native path API (lines + bezier) using m, l, etc.
Example fix
// before
ctx.beginPath();
ctx.moveTo(x, y);
ctx.arcTo(x1, y1, x2, y2, r); // throws [100]
// after: emulate arcTo with lineTo + arc
function arcTo(ctx, x1, y1, x2, y2, r) {
// simplified: draw a quadratic curve to the start of the arc
ctx.lineTo(x1, y1);
// fall back to arc() at the corner as needed
} Defensive patterns
Strategy: fallback
Validate before calling
// arcTo is an unconditional stub — detect the surface before relying on it.
function supportsArcTo(ctx) {
// jsPDF context2d always throws; real <canvas> does not.
// Probe on a throwaway path.
try {
const probe = document.createElement('canvas').getContext('2d');
probe.beginPath();
probe.arcTo(0, 0, 10, 0, 5);
return true;
} catch (e) {
return false;
}
} Type guard
type guard not applicable (method exists; it throws at runtime). Use a capability probe instead:
function isArcToUsable(ctx) {
try { ctx.arcTo(0,0,1,1,1); return true; } catch (e) { return false; }
} Try / catch
try {
ctx.arcTo(x1, y1, x2, y2, r);
} catch (e) {
if (/arcTo not implemented/.test(e.message)) {
// fall back to lineTo/arc emulation
ctx.lineTo(x1, y1);
} else { throw e; }
} Prevention
- Do not assume full Canvas2D parity on jsPDF context2d — maintain a list of unsupported methods (arcTo, toDataURL).
- Centralize rounded-corner drawing in a helper that uses arcTo on real canvas and lineTo/arc on jsPDF.
- Probe capability once per render session and branch accordingly.
When it happens
Trigger: Any call to doc.context2d.arcTo(x1, y1, x2, y2, radius) — or code/porting a real <canvas> script that rounds rectangle corners via arcTo. Libraries that auto-polyfill CanvasRenderingContext2D onto jsPDF will trip it the moment a rounded-corner path is drawn.
Common situations: Porting an existing browser canvas drawing routine to jsPDF's context2d; using a charting/shape library that rounds corners with arcTo; assuming full Canvas2D parity because the object looks like a 2D context.
Related errors
- toDataUrl not implemented.
- Invalid arguments passed to jsPDF.context2d.rect
- Invalid arguments passed to jsPDF.context2d.fillRect
- Invalid arguments passed to jsPDF.context2d.strokeRect
- Invalid arguments passed to jsPDF.context2d.clearRect
AI-assisted analysis of parallax/jsPDF@a3930ce03a (2026-08-13).
Data as JSON: /api/errors/58eb011057c84f47.
Report an issue: GitHub.