react-pdf-viewer
react-pdf-viewer copied to clipboard
Programmatically scroll/change page.
Is there a way to programmatically scroll the document?
I would like to be able to change pages without having to re-render the component with a new initialPage number.
Hey @handofthecode , I managed to get this done using pageNavigationPlugin
:
import { pageNavigationPlugin } from '@react-pdf-viewer/page-navigation';
...
const pageNavigationPluginInstance = pageNavigationPlugin();
const { jumpToPage } = pageNavigationPluginInstance;
Was able to get the number of pages using this:
function onDocumentLoadSuccess(e: DocumentLoadEvent) {
setNumPages(e.doc.numPages);
}
...
<Viewer
...
onDocumentLoad={onDocumentLoadSuccess}
/>