How to make form elements read-only
If you want to make a form field in your document read-only, call setReadOnly(true) on the FormField. While the form field will still be displayed in the document, users won’t be able to edit it. You can call setReadOnly(false) later to unlock the field again.
document.formProvider .getFormFieldWithFullyQualifiedNameAsync("Text Field 1") .subscribe { formField -> formField.setReadOnly(true) }document.getFormProvider() .getFormFieldWithFullyQualifiedNameAsync("Text Field 1") .subscribe(formField -> formField.setReadOnly(true));Registered OnFormFieldUpdatedListeners are notified when the field’s read-only state changes.
The synchronous getFormFieldWithFullyQualifiedName() API may block and shouldn’t be called on the main thread. Use getFormFieldWithFullyQualifiedNameAsync() in UI flows, or call the synchronous API from a background thread.
If you need to prevent filling individual widget annotations, set each widget annotation’s AnnotationFlags.LOCKEDCONTENTS flag. The widget annotation’s READONLY flag doesn’t prevent form filling on Android.
getFormElements() may also block, so use getFormElementsAsync() in UI flows. When updating flags, preserve the annotation’s existing flags:
document.getFormProvider().getFormElementsAsync().subscribe(formElements -> { for (FormElement formElement : formElements) { EnumSet<AnnotationFlags> flags = formElement.getAnnotation().getFlags(); flags.add(AnnotationFlags.LOCKEDCONTENTS); formElement.getAnnotation().setFlags(flags); }});