Skip to content
ComPDF
DemoAPI ReferenceFAQ
Guides

Forms

The ComPDF React Native SDK supports a variety of form events. Commonly used form events include:

Event NameDescription
onFormStyleDialogDismissedTriggered when the form style dialog is dismissed. Returns an event object that contains the form type.
CPDFEvent.FORM_FIELDS_CREATEDTriggered when a user creates form fields. Returns the created form field data.
CPDFEvent.FORM_FIELDS_SELECTEDTriggered when a user selects a form field. Returns the selected form field data.
CPDFEvent.FORM_FIELDS_DESELECTEDTriggered when a user deselects a form field. Returns the deselected form field data.

To listen for these events, pass the dismissal callback when creating CPDFReaderView, or call the event listener functions after the view is created:

tsx
<CPDFReaderView
  ref={pdfReaderRef}
  document={samplePDF}
  configuration={configuration}
  onFormStyleDialogDismissed={(event) => {
    console.log('Form style dialog dismissed:', event.type);
  }}
/>

onFormStyleDialogDismissed returns an event object with the following structure:

tsx
{
  type:
    | 'textField'
    | 'checkBox'
    | 'radioButton'
    | 'listBox'
    | 'comboBox'
    | 'pushButton';
}

Other form events can be listened to after creating the CPDFReaderView:

tsx
pdfReaderRef.current?.addEventListener(
  CPDFEvent.FORM_FIELDS_CREATED,
  (widget) => {
    // 'widget' is a CPDFWidget object or one of its subclasses
  }
);

pdfReaderRef.current?.addEventListener(
  CPDFEvent.FORM_FIELDS_SELECTED,
  (widget) => {
    // 'widget' is a CPDFWidget object or one of its subclasses
  }
);

pdfReaderRef.current?.addEventListener(
  CPDFEvent.FORM_FIELDS_DESELECTED,
  (widget) => {
    // 'widget' is a CPDFWidget object or one of its subclasses
  }
);