parallax/jsPDF · error · Error

Invalid value "{value}" for attribute FT supplied.

Error message

Invalid value "{value}" for attribute FT supplied.

What it means

Thrown by the AcroFormField.FT setter when value is not one of the four valid PDF field types: '/Btn' (button), '/Tx' (text), '/Ch' (choice), '/Sig' (signature). FT is the required Field Type entry (PDF spec). The setter uses a strict switch and rejects anything else, including common mistakes like 'text', 'TextField', or missing the leading slash.

Source

Thrown at src/modules/acroform.js:1197

  });

  var _FT = "";
  Object.defineProperty(this, "FT", {
    enumerable: true,
    configurable: false,
    get: function() {
      return _FT;
    },
    set: function(value) {
      switch (value) {
        case "/Btn":
        case "/Tx":
        case "/Ch":
        case "/Sig":
          _FT = value;
          break;
        default:
          throw new Error(
            'Invalid value "' + value + '" for attribute FT supplied.'
          );
      }
    }
  });

  var _T = null;

  Object.defineProperty(this, "T", {
    enumerable: true,
    configurable: false,
    get: function() {
      if (!_T || _T.length < 1) {
        // In case of a Child from a Radio´Group, you don't need a FieldName
        if (this instanceof AcroFormChildClass) {
          return undefined;
        }
        _T = "FieldObject" + AcroFormField.FieldNum++;

View on GitHub (pinned to a3930ce03a)

Solutions

  1. Use one of the four exact PDF type strings with the leading slash: '/Btn', '/Tx', '/Ch', '/Sig'.
  2. Prefer the concrete field classes provided by the acroform module (Button, TextField, ChoiceField, etc.) which set FT correctly.
  3. Whitelist the value before assignment.

Example fix

// before
field.FT = 'text'; // throws

// after
field.FT = '/Tx';
// or use the typed constructor
var tf = new doc.AcroFormTextField();
Defensive patterns

Strategy: validation

Validate before calling

var VALID_FT = ['/Btn', '/Tx', '/Ch', '/Sig'];
if (VALID_FT.indexOf(value) === -1) {
  throw new Error('FT must be one of ' + VALID_FT.join(', ') + ', got ' + value);
}
field.FT = value;

Type guard

function isValidFT(v) {
  return ['/Btn','/Tx','/Ch','/Sig'].indexOf(v) !== -1;
}

Try / catch

try {
  field.FT = value;
} catch (e) {
  if (/attribute FT supplied/.test(e.message)) {
    throw new Error("FT must be '/Btn', '/Tx', '/Ch', or '/Sig' (note the leading slash)");
  }
  throw e;
}

Prevention

When it happens

Trigger: Setting field.FT to a value without the leading slash (e.g. 'Tx'), a human-readable type name ('text','button'), or any unsupported type.

Common situations: Constructing a custom field and forgetting the '/'; copying a type from documentation that omitted the slash; assigning the wrong constant.

Related errors


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