Programmatically Navigate to a Page

You can programmatically navigate to a page by mutating the viewState of the PSPDFKit instance.

Here’s an example:

const newState = instance.viewState.set("currentPageIndex", 1);

instance.setViewState(newState);

This would navigate the viewer to Page 2 (as the page indices start at 0).

For more information, refer to our API entry on updating the UI state.