{"record":{"id":"f99b61fb9bb7aea1","repo":"parallax/jsPDF","slug":"invalid-value-value-for-attribute-f-supplied","errorCode":null,"errorMessage":"Invalid value \"{value}\" for attribute F supplied.","messagePattern":"Invalid value \"(.+?)\" for attribute F supplied\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/modules/acroform.js","lineNumber":1030,"sourceCode":" * @class AcroFormField\n * @classdesc An AcroForm FieldObject\n */\nvar AcroFormField = function() {\n  AcroFormPDFObject.call(this);\n\n  //Annotation-Flag See Table 165\n  var _F = 4;\n  Object.defineProperty(this, \"F\", {\n    enumerable: false,\n    configurable: false,\n    get: function() {\n      return _F;\n    },\n    set: function(value) {\n      if (!isNaN(value)) {\n        _F = value;\n      } else {\n        throw new Error(\n          'Invalid value \"' + value + '\" for attribute F supplied.'\n        );\n      }\n    }\n  });\n\n  /**\n   * (PDF 1.2) If set, print the annotation when the page is printed. If clear, never print the annotation, regardless of wether is is displayed on the screen.\n   * NOTE 2 This can be useful for annotations representing interactive pushbuttons, which would serve no meaningful purpose on the printed page.\n   *\n   * @name AcroFormField#showWhenPrinted\n   * @default true\n   * @type {boolean}\n   */\n  Object.defineProperty(this, \"showWhenPrinted\", {\n    enumerable: true,\n    configurable: true,\n    get: function() {","sourceCodeStart":1012,"sourceCodeEnd":1048,"githubUrl":"https://github.com/parallax/jsPDF/blob/a3930ce03a585a26b2c76d12a0f413ce96f6d1a3/src/modules/acroform.js#L1012-L1048","documentation":"Thrown by the AcroFormField.F setter when the assigned value is NaN. F is the annotation Flags entry (PDF spec Table 165) and must be an integer bitmask; the setter guards with isNaN. The default is 4 (Print). Note: isNaN(undefined) is false and isNaN('') is false, so empty string/undefined sneak through, but true non-numeric strings throw.","triggerScenarios":"Assigning field.F = 'abc' or field.F = NaN, or assigning an object; indirectly, a computed flag value that became NaN.","commonSituations":"Trying to set the print/annotation flag with a descriptive string instead of a bitmask; chaining bit operations that yielded NaN.","solutions":["Assign only integer bitmasks to F, or use the boolean helpers (showWhenPrinted) which manipulate bits correctly.","Coerce with Number() and validate isFinite before assignment.","Leave F at its default unless you specifically need a non-default annotation flag."],"exampleFix":"// before\nfield.F = 'printable'; // throws\n\n// after\nfield.F = 4; // bit 3 = Print\n// or use the helper\nfield.showWhenPrinted = true;","handlingStrategy":"validation","validationCode":"function setF(field, value) {\n  var n = Number(value);\n  if (!isFinite(n)) throw new Error('F must be a numeric bitmask, got ' + value);\n  field.F = n;\n}","typeGuard":"function isNumericFlag(v) {\n  return typeof v === 'number' && isFinite(v);\n}","tryCatchPattern":"try {\n  field.F = value;\n} catch (e) {\n  if (/attribute F supplied/.test(e.message)) {\n    field.F = Number(value) || 4;\n  } else throw e;\n}","preventionTips":["Assign integer bitmasks to F, or use the boolean helpers like showWhenPrinted.","Validate flag values are finite numbers before assignment.","Leave F at its default (4) unless you need a specific annotation flag."],"tags":["acroform","field-validation","bit-flags"],"backgroundTag":null,"analyzedSha":"a3930ce03a585a26b2c76d12a0f413ce96f6d1a3","analyzedAt":"2026-08-13T05:33:39.648Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}