ComPDFKit Web SDK
    Preparing search index...

    A form field: the set of widgets that share a name and a value.

    Index
    • get actions(): Record<string, Action[]>

      Property form of getActions.

      Returns Record<string, Action[]>

    • get children(): Field[]

      Child fields: fields here hold widgets directly with no child fields, so always an empty array.

      Returns Field[]

    • get defaultValue(): string

      Default value (/DV): readable and writable (a text string) for text fields and combo boxes / lists; for check boxes / radios /DV is a name, which the Worker does not write, and reads as an empty string. On assignment written to each widget, then updateAnnotation commits.

      Returns string

    • set defaultValue(value: string | number): void

      Default value (/DV): readable and writable (a text string) for text fields and combo boxes / lists; for check boxes / radios /DV is a name, which the Worker does not write, and reads as an empty string. On assignment written to each widget, then updateAnnotation commits.

      Parameters

      • value: string | number

      Returns void

    • get exportValue(): FieldValue

      Export value: the first widget's export value for buttons, otherwise the field value.

      Returns FieldValue

    • get flags(): WidgetFlags

      Field flags: those of the first widget (or those given at creation without widgets); on assignment each widget gets a copy, then updateAnnotation commits.

      Returns WidgetFlags

    • set flags(flags: WidgetFlags): void

      Field flags: those of the first widget (or those given at creation without widgets); on assignment each widget gets a copy, then updateAnnotation commits.

      Parameters

      Returns void

    • get font(): Font

      Font of the field: taken from the first widget (the engine reads and writes /DA on widgets); an empty font without widgets.

      Returns Font

    • get IsModified(): boolean

      Some widget has uncommitted changes.

      Returns boolean

    • get options(): { displayValue: string; value: string }[] | null

      Options of combo boxes / lists; always null for other types. On assignment written to each widget, then updateAnnotation commits.

      Returns { displayValue: string; value: string }[] | null

      • { displayValue: string; value: string }[]
        • displayValue: string

          Text shown for the option.

        • value: string

          Export value of the option.

      • null
    • set options(options: { displayValue?: string; value: string }[] | null): void

      Options of combo boxes / lists; always null for other types. On assignment written to each widget, then updateAnnotation commits.

      Parameters

      • options: { displayValue?: string; value: string }[] | null
        • { displayValue?: string; value: string }[]
          • OptionaldisplayValue?: string

            Text shown for the option; defaults to value.

          • value: string

            Export value of the option.

        • null

      Returns void

    • get quadding(): string

      Text alignment: that of the first widget.

      Returns string

    • get tooltipName(): string

      Tooltip (/TU); on assignment written to each widget, then updateAnnotation commits.

      Returns string

    • set tooltipName(text: string): void

      Tooltip (/TU); on assignment written to each widget, then updateAnnotation commits.

      Parameters

      • text: string

      Returns void

    • get value(): FieldValue

      Property form of getValue / setValue; on assignment a failed commit (such as in read-only mode) only logs a warning; use setValue / commit to await the result.

      Returns FieldValue

    • set value(value: FieldValue): void

      Property form of getValue / setValue; on assignment a failed commit (such as in read-only mode) only logs a warning; use setValue / commit to await the result.

      Parameters

      • value: FieldValue

      Returns void

    • The second argument is the type, or the options { type, value, flags }.

      Parameters

      • name: string

        Fully qualified name of the field.

      • Optionaloptions:
            | FieldType
            | {
                flags?: WidgetFlags;
                type?: FieldType | undefined;
                value?: FieldValue | undefined;
            }

        The field type, or the type, initial value and flags.

        • FieldType
        • {
              flags?: WidgetFlags;
              type?: FieldType | undefined;
              value?: FieldValue | undefined;
          }
          • Optionalflags?: WidgetFlags

            Initial field flags.

          • Optionaltype?: FieldType | undefined

            Field type; 'Tx' by default.

          • Optionalvalue?: FieldValue | undefined

            Initial value.

      Returns Field

    • Same as setValue (commit may also run validation actions, but there are no scripts here, so it just sets the value); widget is only a hint, the value belongs to the whole field.

      Parameters

      Returns Promise<void>

    • Actions of the field: those on the first widget (button click actions and so on).

      Returns Record<string, Action[]>

    • Gets the field type.

      Returns FieldType

      'Tx', 'Btn', 'Ch' or 'Sig'.

    • The user this field belongs to (exported and imported with the XFDF field definition, not written to the PDF).

      Returns string

    • An array of selected values for multi-select lists, otherwise a string.

      Returns FieldValue

      const { annotationManager } = instance.Core;
      annotationManager.addEventListener('fieldChanged', (field, value) => {
      console.log(field.name, value, field.getValue());
      });
    • Hides all widgets of the field.

      Returns Promise<void>

    • Fields here hold widgets directly with no child fields.

      Returns boolean

    • Redraws each widget (the appearance is regenerated by the engine after every write).

      Returns void

    • Sets several properties at once: value (set directly), defaultValue, tooltipName, flags, options; missing ones are ignored.

      Parameters

      • options: {
            defaultValue?: string | number;
            flags?: WidgetFlags;
            options?: { displayValue?: string; value: string }[] | null;
            tooltipName?: string;
            value?: FieldValue;
        }
        • OptionaldefaultValue?: string | number

          New default value.

        • Optionalflags?: WidgetFlags

          New field flags.

        • Optionaloptions?: { displayValue?: string; value: string }[] | null

          New options of combo boxes and lists.

        • OptionaltooltipName?: string

          New tooltip (alternate name).

        • Optionalvalue?: FieldValue

          New value.

      Returns void

    • Sets the user this field belongs to (exported and imported with the XFDF field definition, not written to the PDF).

      Parameters

      • user: string

        The user name.

      Returns void

    • Buttons: widgets whose export value equals the value are checked, the rest unchecked; true checks the first widget (check box), false / null unchecks all. Rejects in read-only mode without changing any widget.

      Parameters

      • value: FieldValue

      Returns Promise<void>

      const { annotationManager } = instance.Core;
      const fieldManager = annotationManager.getFieldManager();
      await fieldManager.getField('name').setValue('Jane Doe'); // text field
      await fieldManager.getField('agree').setValue(true); // check box
      await fieldManager.getField('country').setValue('France'); // combo box
    • Shows all widgets of the field.

      Returns Promise<void>

    initialFlags: WidgetFlags | undefined

    Field flags given when creating the field; widgets created with this field carry them.

    initialValue: FieldValue | undefined

    Initial value and flags given when creating the field (options): widgets created with this field carry them.

    name: string

    Fully qualified name of the field.

    type: FieldType

    Field type: 'Tx' (text), 'Btn' (button, check box, radio), 'Ch' (choice) or 'Sig' (signature).

    widgets: WidgetAnnotation[]

    Widgets (form field annotations) of this field.