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:

Event Description
onCloseButtonPressed Called when the close button is pressed.
onStateChanged Called when the PSPDFKitView’s state changed.
onDocumentLoaded Called when the document has been successfully loaded.
onDocumentSaved Called when the document has been successfully saved.
onDocumentSaveFailed Called when the document failed to save.
onDocumentLoadFailed Called when the document failed to load.
onAnnotationTapped Called when the end user tapped on an annotation.
onAnnotationsChanged Called when one or more annotations have changed.
onNavigationButtonClicked Called when the navigation back button is pressed.
onCustomAnnotationContextualMenuItemTapped Called when a custom contextual menu item button is pressed.
onCustomToolbarButtonTapped Called when a custom toolbar button is pressed.
Information

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 from the Catalog example project.