{"record":{"id":"c8be8c516ba17ed8","repo":"parallax/jsPDF","slug":"invalid-arguments-passed-to-jspdf-context2d-transf","errorCode":null,"errorMessage":"Invalid arguments passed to jsPDF.context2d.transform","messagePattern":"Invalid arguments passed to jsPDF\\.context2d\\.transform","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/modules/context2d.js","lineNumber":1508,"sourceCode":"  };\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   */\n  Context2D.prototype.transform = function(a, b, c, d, e, f) {\n    if (isNaN(a) || isNaN(b) || isNaN(c) || isNaN(d) || isNaN(e) || isNaN(f)) {\n      console.error(\"jsPDF.context2d.transform: Invalid arguments\", arguments);\n      throw new Error(\"Invalid arguments passed to jsPDF.context2d.transform\");\n    }\n    var matrix = new Matrix(a, b, c, d, e, f);\n    this.ctx.transform = this.ctx.transform.multiply(matrix);\n  };\n\n  /**\n   * Resets the current transform to the identity matrix. Then runs transform()\n   *\n   * @name setTransform\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 setTransform() method resets the current transform to the identity matrix, and then runs transform() with the same arguments.<br /><br />In other words, the setTransform() method lets you scale, rotate, move, and skew the current context.\n   */","sourceCodeStart":1490,"sourceCodeEnd":1526,"githubUrl":"https://github.com/parallax/jsPDF/blob/a3930ce03a585a26b2c76d12a0f413ce96f6d1a3/src/modules/context2d.js#L1490-L1526","documentation":"transform validates all six matrix components (a,b,c,d,e,f) with isNaN before constructing and multiplying the matrix. Any undefined/missing/non-numeric component throws. This mirrors the HTML5 CanvasTransform.transform signature.","triggerScenarios":"ctx.transform(a,b,c,d,e,f) with fewer than six finite numeric arguments; passing a Matrix object instead of its six components; reading components from a partially-initialized matrix.","commonSituations":"Confusing setTransform/transform (which take six scalars) with applying a Matrix object; spreading a short array into the call; defaulting missing components incorrectly.","solutions":["Always pass six finite numbers; default missing components to the identity (1,0,0,1,0,0).","If you have a Matrix, extract its fields (a,b,c,d,e,f) explicitly rather than passing the object.","Validate all six with Number.isFinite before calling."],"exampleFix":"// before\nctx.transform(...matrixArray); // short array -> throws [112]\n\n// after\nconst [a=1,b=0,c=0,d=1,e=0,f=0] = matrixArray.map(Number);\nif ([a,b,c,d,e,f].every(Number.isFinite)) ctx.transform(a,b,c,d,e,f);","handlingStrategy":"validation","validationCode":"function safeTransform(ctx, a, b, c, d, e, f) {\n  // default to identity for missing components\n  const m = [a ?? 1, b ?? 0, c ?? 0, d ?? 1, e ?? 0, f ?? 0].map(Number);\n  if (!m.every(Number.isFinite)) return;\n  ctx.transform(...m);\n}","typeGuard":"function isTransformArgs(a,b,c,d,e,f) {\n  return [a,b,c,d,e,f].every(v => typeof v === 'number' && Number.isFinite(v));\n}","tryCatchPattern":"try { ctx.transform(a, b, c, d, e, f); }\ncatch (e2) { if (!/context2d.transform/.test(e2.message)) throw e2; }","preventionTips":["Always pass six scalar components, never a Matrix object.","When spreading an array, ensure length === 6.","Default missing components to identity values (1,0,0,1,0,0)."],"tags":["canvas2d","context2d","validation","transform","matrix","nan","pdf"],"backgroundTag":null,"analyzedSha":"a3930ce03a585a26b2c76d12a0f413ce96f6d1a3","analyzedAt":"2026-08-13T05:33:39.648Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}