Guides
Page Navigation
When displaying a PDF using the CPDFReaderView
component, you can perform the following actions via the API:
Jump to a specific page
tsx
await pdfReaderRef.current?.setDisplayPageIndex(1);
1
Get the current page number
tsx
const pageIndex = await pdfReaderRef.current?.getCurrentPageIndex();
1
You can also set a page listener when using CPDFReaderView
to get the current page number in real-time as you scroll.
tsx
const pdfReaderRef = useRef<CPDFReaderView>(null);
<CPDFReaderView
ref={pdfReaderRef}
document={samplePDF}
onPageChanged={onPageChanged}
configuration={ComPDFKit.getDefaultConfig({
})} />
const onPageChanged = (pageIndex: number) => {
console.log('ComPDFKitRN --- onPageChanged:', pageIndex);
}
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11