Max Max - 1 year ago 95
Android Question

How to get the current page number of a PDF in Android

I have to implement a custom PDF Viewer in my Android application, I have implemented this:

To open my pdf I used this function:

/* Load PDF in the activity */
private void openPDF(){
File file = new File(Environment.getExternalStorageDirectory().getAbsolutePath() +"/Download/verbale.pdf");
PDFView pdfView = (PDFView) findViewById(;

.scrollHandle(new DefaultScrollHandle(this))

The PDF is correctly rendered but now I need to get the page number of the page during the scroll.

How I can do this ?

I have tried to use this:


But not it doesn't work...

Answer Source

You can take a look at the official example of the AndroidPdfViewer: Link

Take a look at this two snippets from that example:

1) Create your PDFView:

                .scrollHandle(new DefaultScrollHandle(this))

2) and implement onPageChanged(..):

public void onPageChanged(int page, int pageCount) {
    pageNumber = page;
    //do what you want with the pageNumber

Also don't forget to implement OnPageChangeListener

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download