PDF form events and notifications
Nutrient React Native SDK lets you detect when one or more forms have changed via the AnnotationEvent
event listeners. Here’s how to register for the event listeners to be notified when one or more forms have changed:
override componentDidMount() { this.pdfRef.current?.getNotificationCenter().subscribe(NotificationCenter.AnnotationsEvent.CHANGED, (event: any) => { Alert.alert('PSPDFKit', JSON.stringify(event)); }); this.pdfRef.current?.getNotificationCenter().subscribe(NotificationCenter.AnnotationsEvent.ADDED, (event: any) => { Alert.alert('PSPDFKit', JSON.stringify(event)); }); this.pdfRef.current?.getNotificationCenter().subscribe(NotificationCenter.AnnotationsEvent.REMOVED, (event: any) => { Alert.alert('PSPDFKit', JSON.stringify(event)); }); }
When done, remember to unregister from the event listeners:
override componentWillUnmount () { this.pdfRef.current?.getNotificationCenter().unsubscribe(NotificationCenter.AnnotationsEvent.CHANGED); this.pdfRef.current?.getNotificationCenter().unsubscribe(NotificationCenter.AnnotationsEvent.ADDED); this.pdfRef.current?.getNotificationCenter().unsubscribe(NotificationCenter.AnnotationsEvent.REMOVED); }
For a list of all the additional form-related events you can register for, see FormFieldEvent
.