7

I'm trying to read pdf files in my android application. 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. Therefore I need to make my own pdf reader. I did some research and came across muPDF and Android PDF Viewer Library.

  1. I tried to follow tutorial to implement Android PDF Viewer Library, from the github description. But the problem is that it loads pdf file forever. 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? 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?

Thank you, hopefully, I will be able to solve my problem

a2800276
  • 3,003
  • 18
  • 30
dmacan23
  • 655
  • 1
  • 9
  • 17

5 Answers5

7

MuPDF is a very good library, you can definitely use it. 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.

Librelio
  • 491
  • 3
  • 9
  • 6
    This project seems pretty good but complicated, do you have anything simpler than this. Because I really need just opening PDF activity and going through PDF pages. I don't need any advanced animations, text highlighting etc. If you have no simpler example, then could you tell me what I need from this project to implement to get a simple PDF reading app? – dmacan23 Oct 22 '13 at 06:51
  • After import projects (StartupActivity, main) to eclipse, and change target sdk to 19, and add appcompact7 as library to StartupActivity, i get this errors: http://uupload.ir/files/04yu_1euntitled.png ;;;;; Did you have any sample.apk? I want to see this complete example. Thanks. – Dr.jacky Jun 15 '15 at 08:14
7

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).

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. 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.

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).

Hope this helps, even if it is not a real answer to your question.

Andy
  • 16,265
  • 9
  • 48
  • 69
valleymanbs
  • 477
  • 3
  • 14
6

This is how I succeeded in building a MuPDF lib on windows with Cygwin, android-ndk

  1. Download MuPDF 1.3 Source from https://code.google.com/p/mupdf/downloads/list unzip to folder 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

  3. Make generate. open cygwin terminal, run

    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

    c:/android-ndk-r9d
    
  5. Build mupdf lib: on windows cmd console:

    • preparation:

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

      edit local.properties, uncomment

      #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:

      /android-ndk-r9d/ndk-build
      

      Upon the completion of the build, a folder named libs will be created under

      c:/mupdf-1.3-source/platform/android
      
  6. Create 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.

Yurii
  • 4,583
  • 7
  • 30
  • 37
billowavetor
  • 61
  • 1
  • 2
3

Starting with Android 5.0 you can also use Android's internal PDF renderer and for manipulating PDF you can always use iTextg - just some alternatives for the future.

pkzip
  • 71
  • 4
0

This SO answer lists some steps on how to rip essential pieces from the MuPDF Java sample app to one's own.

Preferably, I'd like to have a "ready to use" Java library I could attach to as a dependency. Is JNI preventing this or is it simply that no-one's gotten up to doing one?

Well, jmupdf is there (mentioned in this duplicate) but that lists Windows and Linux (not specifically Android) as the tested platforms. It seems desktop and dead to me (no changes in 12 months). At least compared to the vibrance of MuPDF itself.

Community
  • 1
  • 1
akauppi
  • 14,244
  • 12
  • 73
  • 94