Programmatically Navigate to Page

Q: Is it possible to programmatically navigate to a specific page?

A: 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, see our API entry on updating the UI state.