Skip to content
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);

Get the current page number

tsx
const pageIndex = await pdfReaderRef.current?.getCurrentPageIndex();

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);
}