简体   繁体   中英

Open password protected pdf file

I am developing a pdf reader[eBook Reader, which can display pdf file], as android don't have any native pdf viewer so i have to use third party pdf viewer. in that case i have choose the Adobe pdf viewer for android. I can open pdf file which are stored in sdcard of my device. Now i want to open password protected pdf file from my application. If user wants to open password protected pdf file manually then use have to provide password while opening.

but i want to open those password pdf file from my application without any password prompt. Application provide the password,[apps knows the password] and without any password prompt, pdf will open.

currently if i want to open any password protected pdf file from my application then a password prompt is appeared and needs a password to open it.

I am using this code to open pdf from my stored pdf files in the SDCARD.

====

File pdfFile = new File(fileLocation); 
if (pdfFile.exists()) 
{ 
    Uri pdfFilepathUri = Uri.fromFile(pdfFile); 
    Intent intent = new Intent(Intent.ACTION_VIEW);    
    intent.setDataAndType(pdfFilepathUri, "application/pdf");
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 
    try 
    { 
        startActivity(intent);
    } 
    catch (ActivityNotFoundException e) 
    { 
        Toast.makeText(this,"No Application Available to View PDF : "+fileLocation,Toast.LENGTH_LONG).show(); 
    } 
}
else Toast.makeText(this,"File cannot found : "+fileLocation,Toast.LENGTH_SHORT).show(); 

====

can anybody please help how can i provide the password from the application, so that it can open pdf file automatically without prompting any password window. ?

in that case i have choose the Adobe pdf viewer for android

What you choose is immaterial. It is what users choose that matters.

but i want to open those password pdf file from my application without any password prompt.

Hopefully, this is not supported. Due to the way Android caches some Intents used for starting activities, any application would be able to steal the password.

Regardless, there is nothing in the ACTION_VIEW standard for this.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM