【发布时间】:2012-03-17 02:42:36
【问题描述】:
我希望能够从我的应用程序中打开一个 pdf 文件,而无需任何其他应用程序,例如 pdf 查看器。我不想让用户安装其他应用程序来打开 pdf 文件。 有没有可以在我的项目中使用的开源库?
【问题讨论】:
-
我不想复制类,我问是否有一个库可以集成到我的项目中,而不是直接调用库函数
标签: android
我希望能够从我的应用程序中打开一个 pdf 文件,而无需任何其他应用程序,例如 pdf 查看器。我不想让用户安装其他应用程序来打开 pdf 文件。 有没有可以在我的项目中使用的开源库?
【问题讨论】:
标签: android
您可以使用 google 文档在 web 视图中打开 PDF。网址格式为
https://docs.google.com/gview?embedded=true&url=http://link.to.your/pdf_file.pdf
【讨论】:
例如,您可以使用 MuPdf 阅读器。我描述了如何构建它here。
【讨论】:
您可以使用 google 文档在 web 视图中打开 PDF。网址格式为
https://docs.google.com/gview?embedded=true&url=http://link.to.your/yourfile.pdf
或者您可以使用 pdf 查看器打开 pdf 遵循此代码
FileFinalpath = SdCardpath + "/" + Filepath + Filename;
File file = new File(FileFinalpath);
if (file.exists()) {
Uri filepath = Uri.fromFile(file);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(filepath, "application/pdf");
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
try {
startActivity(intent);
} catch (Exception e) {
alert.showAlertDialog(PDF_Activity.this, "File Not Started...","File Not Started From SdCard ", false);
Log.e("error", "" + e);
}
} else {
alert.showAlertDialog(PDF_Activity.this, "File Not Found...","File Not Found From SdCard ", false);
}
【讨论】: