parallax/jsPDF · error · Error

addImage does not support files of type '{format}', please e

Error message

addImage does not support files of type '{format}', please ensure that a plugin for '{format}' support is added.

What it means

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.

Source

Thrown at src/modules/addimage.js:881

      var tmpImageData = convertBase64ToBinaryString(imageData, false);

      if (tmpImageData !== "") {
        imageData = tmpImageData;
      } else {
        tmpImageData = jsPDFAPI.loadFile(imageData, true);
        if (tmpImageData !== undefined) {
          imageData = tmpImageData;
        }
      }
    }

    if (isDOMElement(imageData)) {
      imageData = getImageDataFromElement(imageData, format);
    }

    format = getImageFileTypeByImageData(imageData, format);
    if (!isImageTypeSupported(format)) {
      throw new Error(
        "addImage does not support files of type '" +
          format +
          "', please ensure that a plugin for '" +
          format +
          "' support is added."
      );
    }

    // now do the heavy lifting

    if (notDefined(alias)) {
      alias = generateAliasFromImageData(imageData);
    }
    result = checkImagesForAlias.call(this, alias);

    if (!result) {
      // no need to convert if imageData is already uint8array
      if (!(imageData instanceof Uint8Array) && format !== "RGBA") {

View on GitHub (pinned to a3930ce03a)

Solutions

  1. Ensure the appropriate image support plugin is loaded: import 'jspdf-autotable' or include png_support/jpeg_support modules in your build
  2. Use the full jsPDF bundle which includes all image processors: import { jsPDF } from 'jspdf'
  3. Explicitly specify the format argument so auto-detection has a fallback: doc.addImage(data, 'JPEG', x, y, w, h)
  4. Check supported formats at runtime: if (typeof doc['process' + format.toUpperCase()] === 'function') before calling addImage

Example fix

// before - missing PNG support in build
doc.addImage(pngData, 'PNG', 10, 10); // throws

// after - ensure full build or load plugin
import { jsPDF } from 'jspdf'; // full build includes image processors
// or specify format explicitly if data is identifiable
doc.addImage(data, 'JPEG', 10, 10); // use a supported format
Defensive patterns

Strategy: validation

Validate before calling

// Check if image format is supported before calling addImage
function isFormatSupported(doc, format) {
  return typeof doc['process' + format.toUpperCase()] === 'function';
}

var format = 'PNG';
if (isFormatSupported(doc, format)) {
  doc.addImage(data, format, 10, 10);
} else {
  console.error('Image format ' + format + ' is not supported. Load the appropriate plugin.');
}

Type guard

/**
 * @param {jsPDF} doc
 * @param {string} format
 * @returns {boolean}
 */
function isImageTypeSupported(doc, format) {
  return typeof doc.internal.getFilters === 'function' &&
    typeof doc['process' + String(format).toUpperCase()] === 'function';
}

Try / catch

try {
  doc.addImage(data, format, 10, 10);
} catch (e) {
  if (e.message.includes('does not support files of type')) {
    // Convert to supported format using canvas
    var canvas = document.createElement('canvas');
    // ... draw image and convert to PNG/JPEG ...
    doc.addImage(canvas.toDataURL('image/png'), 'PNG', 10, 10);
  } else throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of parallax/jsPDF@a3930ce03a (2026-08-13). Data as JSON: /api/errors/6daaf631160e8123. Report an issue: GitHub.