Some test text!

Search
Hamburger Icon

Web / Guides

Adding form field indicators

The following code adds indicator text to all the form fields after the annotationsLoaded promise has resolved.

Note this feature is for WebViewer 8.9+
WebViewer(...)
.then(instance => {
  const { documentViewer, annotationManager, Annotations } = instance.Core;

  const addIndicator = (widget) => {
    widget.setFieldIndicator(true, 'Insert text here');
  };

  documentViewer.addEventListener('annotationsLoaded', () => {
    const widgetAnnotations = annotationManager.getAnnotationsList().filter(annotation => annotation instanceof Annotations.WidgetAnnotation);
    widgetAnnotations.forEach(addIndicator);

    annotationManager.trigger('annotationChanged', [widgetAnnotations, 'modify', {}]);
  });
});
Note the annotationChanged event is triggered afterwards so that the indicators update after the changes to the fields' widgets are made

Toggle form field indicators

You can choose to hide form field indicators when they would normally be shown using the hideFormFieldIndicators API.

Likewise, you can also choose to show form field indicators if they have been hidden using the showFormFieldIndicators API.

Set form field indicators programatically

You can choose to hide form field indicators when they would normally be shown or show them when they are hidden, and change the text that they contain using the setFieldIndicator API.

Get the answers you need: Chat with us