Androidpdfviewer: How to verify password for encrypted pdf file?

Created on 18 Dec 2017  Â·  8Comments  Â·  Source: barteksc/AndroidPdfViewer

If this file is encrypted, how do you automatically pop a window to prompt the user to enter a password?
a dialog and callback.

Most helpful comment

If you were struggling... this will help..

.onError(new OnErrorListener() {
@Override
public void onError(Throwable t) {
if (t instanceof PdfPasswordException) {
//add your code here
}
}
}

All 8 comments

You add your own code to do this, as you said pop up a dialog and then reload the pdf with the password no callback in a sense. Just reload the pdf.

Hi, how do I detect this PDF file with a password?

Simply catch the error then show your dialog box and reload pdfviewer with the new password inputted by the user.

yeah, thanks a lot.

If you were struggling... this will help..

.onError(new OnErrorListener() {
@Override
public void onError(Throwable t) {
if (t instanceof PdfPasswordException) {
//add your code here
}
}
}

thanks, I've done it like you did.
but the pdf file was parsed twice..

Every PDF reader works that way

Thanks @barteksc @1stmetro

Was this page helpful?
0 / 5 - 0 ratings