PDF Form Field Flags in iOS

Flags are sets of Boolean properties on an object. Each form field and form element in a document has flags that define behavior and capabilities. A form field tracks the entered data value. A form element is the visual object shown on a PDF page, and it’s represented by a widget annotation.

General Field Flags

The isReadOnly, isRequired, and isNoExport flags are available on all types of form fields: button fields, text fields, choice fields, and signature fields.

  • If the isReadOnly flag is true, then the UI won’t allow the form field to be filled or its value to be changed. You can also use the isEditable property on the form field as a transient property to disable user interaction. In other words, isReadOnly is persisted in the PDF, while isEditable isn’t. Note that the .readOnly and .lockedContents flags on the form element have no effect.

  • The isRequired flag is exposed but only partially supported. The elements of any fields marked as required will be displayed with a red border. However, PSPDFKit will allow form submission actions to run, even if some required form fields are empty.

  • The isNoExport flag is exposed but not supported.

Button Field Flags

The isPushButton, isCheckBox, and isRadioButton properties can be used to read the type of a button field.

The NoToggleToOff and RadiosInUnison flags from the PDF reference aren’t exposed or supported.

Text Field Flags

The isMultiLine, isPassword, isComb, and doNotScroll flags are available to alter the behavior and appearance of text fields.

The isRichText, doNotSpellCheck, and fileSelect flags are exposed but not supported.

Choice Field Flags

The isCombo and isEdit properties can be used to read the type of a choice field:

  • If both isCombo and isEdit are enabled, then the field is a combo box, which allows picking from a list or entering custom text. In this case, isMultiSelect isn’t supported.

  • If only isCombo is enabled, then the field shows a dropdown list, without the option to enter custom text. In this case, isMultiSelect isn’t supported.

  • If isCombo isn’t enabled, then the field is a list box, which shows a list of options inline on the page. In this case, the isMultiSelect flag may be enabled, but the isEdit flag is ignored.

The commitOnSelChange and doNotSpellCheck flags are exposed but not supported.

The Sort flag from the PDF reference isn’t exposed because the reference states that this flag isn’t intended to be used by PDF readers.

Form Element Flags

Since form elements are a type of widget annotation, you can access form element flags using the flags property inherited from Annotation. Therefore, the API for working with form element flags is mostly the same as the API for annotation flags. These can be used to make form elements hidden. See our Annotation Flags guide to learn more.

There are some exceptions for forms:

  • PSPDFKit doesn’t provide any UI to edit form elements themselves, such as one for moving or resizing an element. Therefore, the .locked flag has no effect because there’s nothing to lock.

  • The .readOnly and .lockedContents flags are ignored. Instead, to prevent a user from filling in a form, use the isReadOnly property of the associated form field.