Search code examples
androidmupdf

How to get current page in MuPDF?


I need to go to the same page on a PDF document after screen change. I have found how to navigate to page here but I failed to get the current page number.

I have found some codes regarding this in MuPDF library but couldn't call it from main activity. In PageView class (MuPDFPageView extends PageView):

public int getPage() {
    return mPageNumber;
}

The problem is I don't know how to call this from main activity. I tried something like this:

final MuPDFPageView pageView = new MuPDFPageView(getApplicationContext(), filePickerSupport, core, parentSize, sharedHqBm);
int i = pageView.getPage();

But failed to fill the parameters in. Anybody has a better or easier way to get the current page number?


Solution

  • Within MuPDFActivity, you can call:

    mDocView.getDisplayedViewIndex()

    and that will return you the current page number.