{"record":{"id":"b53beaf6ebeed825","repo":"parallax/jsPDF","slug":"invalid-arguments-passed-to-jspdf-context2d-transl","errorCode":null,"errorMessage":"Invalid arguments passed to jsPDF.context2d.translate","messagePattern":"Invalid arguments passed to jsPDF\\.context2d\\.translate","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/modules/context2d.js","lineNumber":1486,"sourceCode":"      0.0,\n      0.0\n    );\n    this.ctx.transform = this.ctx.transform.multiply(matrix);\n  };\n\n  /**\n   * Remaps the (0,0) position on the canvas\n   *\n   * @name translate\n   * @function\n   * @param x {Number} The value to add to horizontal (x) coordinates\n   * @param y {Number} The value to add to vertical (y) coordinates\n   * @description The translate() method remaps the (0,0) position on the canvas.\n   */\n  Context2D.prototype.translate = function(x, y) {\n    if (isNaN(x) || isNaN(y)) {\n      console.error(\"jsPDF.context2d.translate: Invalid arguments\", arguments);\n      throw new Error(\"Invalid arguments passed to jsPDF.context2d.translate\");\n    }\n    var matrix = new Matrix(1.0, 0.0, 0.0, 1.0, x, y);\n    this.ctx.transform = this.ctx.transform.multiply(matrix);\n  };\n\n  /**\n   * Replaces the current transformation matrix for the drawing\n   *\n   * @name transform\n   * @function\n   * @param a {Number} Horizontal scaling\n   * @param b {Number} Horizontal skewing\n   * @param c {Number} Vertical skewing\n   * @param d {Number} Vertical scaling\n   * @param e {Number} Horizontal moving\n   * @param f {Number} Vertical moving\n   * @description Each object on the canvas has a current transformation matrix.<br /><br />The transform() method replaces the current transformation matrix. It multiplies the current transformation matrix with the matrix described by:<br /><br /><br /><br />a    c    e<br /><br />b    d    f<br /><br />0    0    1<br /><br />In other words, the transform() method lets you scale, rotate, move, and skew the current context.\n   */","sourceCodeStart":1468,"sourceCodeEnd":1504,"githubUrl":"https://github.com/parallax/jsPDF/blob/a3930ce03a585a26b2c76d12a0f413ce96f6d1a3/src/modules/context2d.js#L1468-L1504","documentation":"translate validates x and y with isNaN before multiplying the translation matrix into the context transform. Omitting either argument or passing non-numeric values throws.","triggerScenarios":"ctx.translate(x, y) with either argument undefined, omitted, or non-numeric; reading offsets from an unset origin object.","commonSituations":"Translating by computed deltas where one component is missing; passing a single argument expecting (x,x); stringified coordinates from config.","solutions":["Pass two finite numbers; default missing to 0.","Guard: if (Number.isFinite(+x) && Number.isFinite(+y)) ctx.translate(+x, +y);","Coerce with Number() upstream in your layout pipeline."],"exampleFix":"// before\nctx.translate(origin.x, origin.y); // origin.y undefined -> throws [111]\n\n// after\nctx.translate(+origin.x || 0, +origin.y || 0);","handlingStrategy":"validation","validationCode":"function safeTranslate(ctx, x, y) {\n  ctx.translate(Number.isFinite(+x) ? +x : 0, Number.isFinite(+y) ? +y : 0);\n}","typeGuard":"function isTranslateArgs(x, y) { return Number.isFinite(+x) && Number.isFinite(+y); }","tryCatchPattern":"try { ctx.translate(x, y); }\ncatch (e) { if (!/context2d.translate/.test(e.message)) throw e; }","preventionTips":["Pass two finite numbers; default missing to 0.","Coerce offset objects at the layout boundary."],"tags":["canvas2d","context2d","validation","transform","nan","pdf"],"backgroundTag":null,"analyzedSha":"a3930ce03a585a26b2c76d12a0f413ce96f6d1a3","analyzedAt":"2026-08-13T05:33:39.648Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}