Foxit PDF SDK for Android

What should I do if I want to display a specified page when opening a PDF document using PDF SDK for Android?

To display a specified page when opening a PDF file, the interface gotoPage (int pageIndex) should be used. Foxit PDF SDK for Android utilizes multi-thread to improve rendering speed, so please make sure the document has been loaded successfully before using the gotoPage interface.

Please implement the callback interface in the IDocEventListener, and then call the gotoPage interface in the onDocOpened event. Following is the sample code:

//Assuming A PDFViewCtrl has been created.

// Register the PDF document event listener 
pdfViewCtrl.registerDocEventListener(docListener);

// Open an unencrypted PDF document from a specified PDF file path.
String path = "/mnt/sdcard/input_files/Sample.pdf";
pdfViewCtrl.openDoc(path, null);
...
PDFViewCtrl.IDocEventListener docListener = new PDFViewCtrl.IDocEventListener() {

@Override
public void onDocWillOpen() {
}

@Override
public void onDocOpened(PDFDoc pdfDoc, int errCode) {
pdfViewCtrl.gotoPage(2);
}

@Override
public void onDocWillClose(PDFDoc pdfDoc) {
}

@Override
public void onDocClosed(PDFDoc pdfDoc, int i) {
}

@Override
public void onDocWillSave(PDFDoc pdfDoc) {
}

@Override
public void onDocSaved(PDFDoc pdfDoc, int i) {
}

@Override
public void onDocModified(PDFDoc pdfDoc) {
}
};

Updated on August 28, 2018

Was this article helpful?
Thanks for your feedback. If you have a comment on how to improve the article, you can write it here: