![](/img/trans.png)
[英]How to open a programmatically protected PDF file [Not password protected]
[英]How to open password protected pdf file by providing password in android application programmatically
我正在开发pdf阅读器,因为android没有任何本机pdf查看器,所以我必须使用第三方pdf查看器。 在这种情况下,我选择了Android的Adobe pdf查看器。 我可以打开存储在设备sdcard中的pdf文件。 现在,我想从应用程序中打开受密码保护的pdf文件。 如果用户想手动打开受密码保护的pdf文件,则必须在打开时提供密码。 但是我想从我的应用程序中打开那些密码pdf文件,而没有任何密码提示。 应用程序提供密码,[应用程序知道密码],并且在没有任何密码提示的情况下,pdf将打开。
当前,如果我想从应用程序中打开任何受密码保护的pdf文件,则会出现密码提示,并需要密码才能打开它。
我正在使用此代码从/ mnt / sdcard / testfolder中存储的pdf文件中打开pdf
protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
PackageManager packageManager = getPackageManager();
Intent testIntent = new Intent(Intent.ACTION_VIEW);
testIntent.setType("application/pdf");
List list = packageManager.queryIntentActivities(testIntent,
PackageManager.MATCH_DEFAULT_ONLY);
if (list.size() > 0 && imagelist[(int) id].isFile()) {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
Uri uri = Uri.fromFile(imagelist[(int) id].getAbsoluteFile());
intent.setDataAndType(uri, "application/pdf");
startActivity(intent);
}
}
如何通过在Android应用程序中以编程方式提供密码来打开受密码保护的pdf文件。请帮助:(
取决于打开文件的应用程序。 有了此代码后,Android会查找用户安装的可打开pdf文件的应用。 有些应用无法打开受密码保护的pdf文件。
如果pdf受密码保护并且应用可以对其进行管理,则pdf应用会要求用户输入密码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.