2012-02-27 72 views
3

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

+0

[android中自定义PDF阅读器]的可能重复(http://stackoverflow.com/questions打开PDF/4592384 /自定义PDF查看器功能于Android设备) – mah 2012-02-27 16:10:40

+0

我不想COPI班,我asqued如果有,我可以在我的项目整合,不是直接调用库函数 – 2012-02-27 16:57:24

回答

2

可以使用,例如,MuPdf读者。我描述了如何建立它here

+0

终于让我找到我们需要安装NDK,Android和cygwin的解决方案。那么我们可以从.c文件构建.so。 欲了解更多解释,你可以看到这一点,它非常帮助我: http://mindtherobot.com/blog/452/android-beginners-ndk-setup-step-by-step/ – 2012-02-29 14:45:38

+0

但你不要问对这个 ) – Yury 2012-02-29 14:53:57

3

您可以使用谷歌文档在webview中打开PDF。 URL格式是

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

+0

我得到这个答案库:对不起,我们可以找到文件和原始来源。证明文件仍然存在。 请我看不到文档,所以如果你看到它发送请:[email protected] – 2012-02-27 20:24:04

0

您可以使用谷歌文档在webview中打开PDF。 URL格式是

https://docs.google.com/gview?embedded=true&url=http://link.to.your/yourfile.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);    

      } 
相关问题