PDF viewer events

Nutrient React Native SDK lets you listen to various events that occur when the end user interacts with Nutrient.

The following table lists the events supported by Nutrient React Native SDK on the main namespace:

EventDescription
onCloseButtonPressedCalled when the close button is pressed.
onStateChangedCalled when the PSPDFKitView’s state changed.
onDocumentLoadedCalled when the document has been successfully loaded.
onDocumentSavedCalled when the document has been successfully saved.
onDocumentSaveFailedCalled when the document failed to save.
onDocumentLoadFailedCalled when the document failed to load.
onAnnotationTappedCalled when the end user tapped on an annotation.
onAnnotationsChangedCalled when one or more annotations have changed.
onNavigationButtonClickedCalled when the navigation back button is pressed.
onCustomAnnotationContextualMenuItemTappedCalled when a custom contextual menu item button is pressed.
onCustomToolbarButtonTappedCalled when a custom toolbar button is pressed.

These events are superceded by the Nutrient React Native NotificationCenter.

Implementing an event listener

The example below shows how to implement an event listener to be notified when a document is saved:

<PSPDFKitView
document={DOCUMENT}
onDocumentSaved={(event) => {
if (event['error']) {
alert(event['error']);
} else {
alert('Document Saved!');
}
}}
ref="pdfView"
fragmentTag="PDF1"
style={{ flex: 1 }}
/>

For more details and sample code, see the EventListeners.tsx example(opens in a new tab) from the Catalog example project.