import { pageNavigationPlugin } from '@react-pdf-viewer/page-navigation';
const pageNavigationPluginInstance = pageNavigationPlugin();
const { CurrentPageLabel } = pageNavigationPluginInstance;
import { RenderCurrentPageLabelProps } from '@react-pdf-viewer/page-navigation';
return (
<div
style={{
border: '1px solid rgba(0, 0, 0, 0.3)',
display: 'flex',
flexDirection: 'column',
height: '100%',
}}
>
<div
style={{
alignItems: 'center',
backgroundColor: '#eeeeee',
borderBottom: '1px solid rgba(0, 0, 0, 0.3)',
display: 'flex',
justifyContent: 'center',
padding: '8px',
}}
>
<CurrentPageLabel>
{(props: RenderCurrentPageLabelProps) => (
<span>{`${props.currentPage + 1} of ${props.numberOfPages}`}</span>
)}
</CurrentPageLabel>
</div>
<div
style={{
flex: 1,
overflow: 'hidden',
}}
>
<Viewer fileUrl="/assets/pdf-open-parameters.pdf" plugins={[pageNavigationPluginInstance]} />
</div>
</div>
);
In the example below, you can scroll up or down to see the current page is updated.