【问题标题】:android: open a pdf from my app without using pdf viewerandroid:在不使用 pdf 查看器的情况下从我的应用程序打开 pdf
【发布时间】:2012-03-17 02:42:36
【问题描述】:

我希望能够从我的应用程序中打开一个 pdf 文件,而无需任何其他应用程序,例如 pdf 查看器。我不想让用户安装其他应用程序来打开 pdf 文件。 有没有可以在我的项目中使用的开源库?

【问题讨论】:

  • 我不想复制类,我问是否有一个库可以集成到我的项目中,而不是直接调用库函数

标签: android


【解决方案1】:

您可以使用 google 文档在 web 视图中打开 PDF。网址格式为

https://docs.google.com/gview?embedded=true&url=http://link.to.your/pdf_file.pdf

【讨论】:

  • 我得到了这个答案:抱歉,我们可以找到文档和原始来源。验证文档是否仍然存在。请我看不到文档,所以如果你看到它请发送到:haythemmm@gmail.com
【解决方案2】:

例如,您可以使用 MuPdf 阅读器。我描述了如何构建它here

【讨论】:

  • 最后我找到了我们必须安装 ndk-android 和 cygwin 的解决方案。然后我们就可以从 .c 文件构建 .so 了。有关更多解释,您可以看到这一点,它对我很有帮助:mindtherobot.com/blog/452/…
  • 但你不要问这个)
【解决方案3】:

您可以使用 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);             

            }

【讨论】:

    猜你喜欢
    • 2011-02-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-26
    相关资源
    最近更新 更多