{"record":{"id":"6daaf631160e8123","repo":"parallax/jsPDF","slug":"addimage-does-not-support-files-of-type-format","errorCode":null,"errorMessage":"addImage does not support files of type '{format}', please ensure that a plugin for '{format}' support is added.","messagePattern":"addImage does not support files of type '(.+?)', please ensure that a plugin for '(.+?)' support is added\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/modules/addimage.js","lineNumber":881,"sourceCode":"      var tmpImageData = convertBase64ToBinaryString(imageData, false);\n\n      if (tmpImageData !== \"\") {\n        imageData = tmpImageData;\n      } else {\n        tmpImageData = jsPDFAPI.loadFile(imageData, true);\n        if (tmpImageData !== undefined) {\n          imageData = tmpImageData;\n        }\n      }\n    }\n\n    if (isDOMElement(imageData)) {\n      imageData = getImageDataFromElement(imageData, format);\n    }\n\n    format = getImageFileTypeByImageData(imageData, format);\n    if (!isImageTypeSupported(format)) {\n      throw new Error(\n        \"addImage does not support files of type '\" +\n          format +\n          \"', please ensure that a plugin for '\" +\n          format +\n          \"' support is added.\"\n      );\n    }\n\n    // now do the heavy lifting\n\n    if (notDefined(alias)) {\n      alias = generateAliasFromImageData(imageData);\n    }\n    result = checkImagesForAlias.call(this, alias);\n\n    if (!result) {\n      // no need to convert if imageData is already uint8array\n      if (!(imageData instanceof Uint8Array) && format !== \"RGBA\") {","sourceCodeStart":863,"sourceCodeEnd":899,"githubUrl":"https://github.com/parallax/jsPDF/blob/a3930ce03a585a26b2c76d12a0f413ce96f6d1a3/src/modules/addimage.js#L863-L899","documentation":"processImageData checks whether jsPDF has a registered processor for the detected image format by looking for a function named process{FORMAT} on the API (e.g., processPNG, processJPEG). If the format-specific support module (png_support.js, jpeg_support.js, bmp_support.js, etc.) is not loaded, the processor function won't exist and addImage cannot proceed. The format is either auto-detected from magic bytes or taken from the format argument.","triggerScenarios":"Using a custom jsPDF build that excludes image support plugins. Passing a PNG when only JPEG support is loaded. Passing data that jsPDF cannot identify (format resolves to 'UNKNOWN') because magic bytes don't match any known type and no fallback format is provided. Passing WEBP, GIF, or BMP without their respective support modules.","commonSituations":"Using a minimal/tree-shaken jsPDF build. Loading jsPDF from a CDN script tag that only includes core. Working in Node.js where some image support modules require browser APIs. Passing corrupt or truncated image data where magic bytes are missing.","solutions":["Ensure the appropriate image support plugin is loaded: import 'jspdf-autotable' or include png_support/jpeg_support modules in your build","Use the full jsPDF bundle which includes all image processors: import { jsPDF } from 'jspdf'","Explicitly specify the format argument so auto-detection has a fallback: doc.addImage(data, 'JPEG', x, y, w, h)","Check supported formats at runtime: if (typeof doc['process' + format.toUpperCase()] === 'function') before calling addImage"],"exampleFix":"// before - missing PNG support in build\ndoc.addImage(pngData, 'PNG', 10, 10); // throws\n\n// after - ensure full build or load plugin\nimport { jsPDF } from 'jspdf'; // full build includes image processors\n// or specify format explicitly if data is identifiable\ndoc.addImage(data, 'JPEG', 10, 10); // use a supported format","handlingStrategy":"validation","validationCode":"// Check if image format is supported before calling addImage\nfunction isFormatSupported(doc, format) {\n  return typeof doc['process' + format.toUpperCase()] === 'function';\n}\n\nvar format = 'PNG';\nif (isFormatSupported(doc, format)) {\n  doc.addImage(data, format, 10, 10);\n} else {\n  console.error('Image format ' + format + ' is not supported. Load the appropriate plugin.');\n}","typeGuard":"/**\n * @param {jsPDF} doc\n * @param {string} format\n * @returns {boolean}\n */\nfunction isImageTypeSupported(doc, format) {\n  return typeof doc.internal.getFilters === 'function' &&\n    typeof doc['process' + String(format).toUpperCase()] === 'function';\n}","tryCatchPattern":"try {\n  doc.addImage(data, format, 10, 10);\n} catch (e) {\n  if (e.message.includes('does not support files of type')) {\n    // Convert to supported format using canvas\n    var canvas = document.createElement('canvas');\n    // ... draw image and convert to PNG/JPEG ...\n    doc.addImage(canvas.toDataURL('image/png'), 'PNG', 10, 10);\n  } else throw e;\n}","preventionTips":["Use the full jsPDF bundle which includes all image processors","Explicitly specify format as 'PNG' or 'JPEG' which are most commonly supported","Check typeof doc['process' + format.toUpperCase()] === 'function' before calling addImage"],"tags":["addimage","image-format","plugin","unsupported-format"],"backgroundTag":null,"analyzedSha":"a3930ce03a585a26b2c76d12a0f413ce96f6d1a3","analyzedAt":"2026-08-13T05:33:39.648Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}