简体   繁体   English

Android PDF Viewer Library或muPDF库教程

[英]Android PDF Viewer Library or muPDF library tutorials

I'm trying to read pdf files in my android application. 我正在尝试在我的Android应用程序中阅读pdf文件。 I don't want to use the default pdf reader and simply open a new intent because I need my own GUI, and want to use the first page as a cover. 我不想使用默认的pdf阅读器,只是打开一个新的意图,因为我需要自己的GUI,并希望使用第一页作为封面。 Therefore I need to make my own pdf reader. 因此,我需要制作自己的pdf阅读器。 I did some research and came across muPDF and Android PDF Viewer Library . 我做了一些研究,遇到了muPDF和Android PDF Viewer Library

  1. I tried to follow tutorial to implement Android PDF Viewer Library, from the github description. 我试着从github描述中按照教程实现Android PDF Viewer Library。 But the problem is that it loads pdf file forever. 但问题是它永远加载pdf文件。 Do I need to do something else than just the steps in the description? 除了描述中的步骤之外,我还需要做些什么吗?

  2. I can't find any tutorials for the muPDF library, are there any? 我找不到muPDF库的任何教程,有没有? How to implement it? 怎么实现呢?

  3. If there is no useful answer for the previous two questions, are there any good pdf library out there with tutorials and good documentation? 如果对前两个问题没有有用的答案,那么有没有好的pdf库,有教程和良好的文档?

Thank you, hopefully, I will be able to solve my problem 谢谢,希望我能够解决我的问题

MuPDF is a very good library, you can definitely use it. MuPDF是一个非常好的库,你绝对可以使用它。 If you need a complete example of Android app using MuPDF, I suggest you to take a look at this customizable magazine app on Github . 如果您需要使用MuPDF的完整Android应用程序示例,我建议您在Github上查看这个可自定义的杂志应用程序。

first of all, if you want to use MUPDF inside an existing android app project you can follow the guide you find at this link (all credits go to the author, I didn't write this). 首先,如果你想在现有的Android应用程序项目中使用MUPDF,你可以按照你在这个链接找到的指南(所有学分转到作者,我没有写这个)。

I am trying as well to integrate a very simple PDF reading/printing solution inside my app and i am struggling to strip down/simplify the MuPdf application demo you get by following that guide. 我也想在我的应用程序中集成一个非常简单的PDF阅读/打印解决方案,我正在努力通过遵循该指南来删除/简化您获得的MuPdf应用程序演示。 I already managed (somehow) to remove annotation and file-picking features, but i would really need some help as well to get all the job done. 我已经管理(以某种方式)删除注释和文件选择功能,但我真的需要一些帮助来完成所有工作。 There's really a lot of stuff and absolutely no documentation about this. 真的有很多东西,绝对没有关于此的文档。 I am simply trying to read the code and figure out what is needed and what is not, removing features one by one and being driven by the errors you get in catlog. 我只是试图阅读代码并弄清楚需要什么和不需要什么,逐个删除功能并由catlog中的错误驱动。

Also, as we both (if I understood correctly your needs) need just the PDF rendering features, would be great if someone points out how to (if possible) disable some of the unnecessary features built in the MuPDF library when building it from source (as DjVu support, just as an example). 另外,正如我们两个(如果我理解你的需要)只需要PDF渲染功能,如果有人指出如何(如果可能的话)在从源代码构建它时禁用MuPDF库中构建的一些不必要的功能,那将会很棒(作为DjVu的支持,就像一个例子)。

Hope this helps, even if it is not a real answer to your question. 希望这有帮助,即使它不是你的问题的真正答案。

This is how I succeeded in building a MuPDF lib on windows with Cygwin, android-ndk 这就是我用Cygwin,android-ndk在windows上构建MuPDF lib的方法

  1. Download MuPDF 1.3 Source from https://code.google.com/p/mupdf/downloads/list unzip to folder c:/mupdf-1.3-source https://code.google.com/p/mupdf/downloads/list下载MuPDF 1.3源解压缩到文件夹c:/mupdf-1.3-source

  2. Install Cygwin: Download and run Run setup-x86.exe from http://cygwin.com/install.html when installing cygwin, make sure you selected make packages and C++ compilers 安装Cygwin:在安装cygwin时从http://cygwin.com/install.html下载并运行运行setup-x86.exe,确保选择了make packages和C ++编译器

  3. Make generate. 生成。 open cygwin terminal, run 打开cygwin终端,运行

     cd /cygdrive/ cd c/mupdf-1.3-source make generate 
  4. Install android-ndk: download android-ndk-r9d-windows-x86.zip and unzip it to 安装android-ndk:下载android-ndk-r9d-windows-x86.zip并将其解压缩到

     c:/android-ndk-r9d 
  5. Build mupdf lib: on windows cmd console: 在Windows cmd控制台上构建mupdf lib:

    • preparation: 制备:

       cd c:/mupdf-1.3-source/platform/android copy local.properties.sample local.properties 

      edit local.properties, uncomment 编辑local.properties,取消注释

       #sdk.dir=C:\\\\Program Files (x86)\\\\Android\\\\android-sdk 

      and change to 并改为

       sdk.dir=REAL andforid-sdk Folder 
    • build: while still on c:/mupdf-1.3-source/platform/android , run: build:仍在c:/mupdf-1.3-source/platform/android ,运行:

       /android-ndk-r9d/ndk-build 

      Upon the completion of the build, a folder named libs will be created under 完成构建后,将创建一个名为libs的文件夹

       c:/mupdf-1.3-source/platform/android 
  6. Create android apk. 创建android apk。 Open eclipse, create a new android project from existing code, browse to c:/mupdf-1.3-source/platform/android , now you can create a mupdf apk. 打开eclipse,从现有代码创建一个新的android项目,浏览到c:/mupdf-1.3-source/platform/android ,现在你可以创建一个mupdf apk。

从Android 5.0开始,您还可以使用Android的内部PDF渲染器,并且为了操作PDF,您始终可以使用iTextg - 这是未来的一些替代方案。

This SO answer lists some steps on how to rip essential pieces from the MuPDF Java sample app to one's own. 这个SO 答案列出了一些关于如何从MuPDF Java示例应用程序中删除必要部分的步骤。

Preferably, I'd like to have a "ready to use" Java library I could attach to as a dependency. 我希望有一个“可以随时使用”的Java库,我可以作为依赖项附加。 Is JNI preventing this or is it simply that no-one's gotten up to doing one? JNI是否阻止了这一点,还是只是没有人做到这一点?

Well, jmupdf is there (mentioned in this duplicate ) but that lists Windows and Linux (not specifically Android) as the tested platforms. 那么, jmupdf就在那里(在这个副本中提到)但是它将Windows和Linux(不是特别是Android)列为测试平台。 It seems desktop and dead to me (no changes in 12 months). 对我来说似乎是桌面而且死了(12个月内没有变化)。 At least compared to the vibrance of MuPDF itself. 至少与MuPDF本身的振动相比。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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