Skip to content
ComPDF
Guides

Page Navigation

Page navigation lets you quickly move to a specific page or location in a PDF document. After the document is loaded in CPDFReaderView, you can jump to a target page through the API and listen for reader events such as page jumps and scrolling.

This example shows how to navigate to specific pages:

java
// Navigate to the first page.
readerView.setDisplayPageIndex(0);

Get the Current Page Index

java
int pageIndex = readerView.getPageNum();

Listen for Page Navigation and Reader Events

java
readerView.setReaderViewCallback(new IReaderViewCallback() {
  @Override
  public void onTapMainDocArea() {
    // Tap on the main document area
  }

  @Override
  public void onMoveToChild(int pageIndex) {
    // Target page index after navigation
  }

  @Override
  public void onEndScroll() {
    // Scrolling ended
  }

  @Override
  public void onScrolling() {
    // Scrolling in progress
  }

  @Override
  public void onRecordLastJumpPageNum(int pageIndex) {
    // Record the last jumped page index
  }
});
kotlin
readerView.setReaderViewCallback(object : IReaderViewCallback {

    override fun onTapMainDocArea() {
        // Tap on the main document area
    }

    override fun onMoveToChild(pageIndex: Int) {
        // Target page index after navigation
    }

    override fun onEndScroll() {
        // Scrolling ended
    }

    override fun onScrolling() {
        // Scrolling in progress
    }

    override fun onRecordLastJumpPageNum(pageIndex: Int) {
        // Record the last jumped page index
    }
})