1

I was trying to use MuPDF library to open pdf files in my application. I've followed the steps to integrate Mupdf with my project, and it works on my app to display file structure and let me choose pdf files. But when I click a pdf file, it opens a blank screen. It doesn't throw any errors. The MuPDF app I downloaded from the Play market works fine and can render the pdf file normally.

I followed steps in this thread: Integrate MuPDF Reader in an app

i put this part in my activity class file in the hope it would transfer data to the screen:

To open pdf with pre-fix file:

    Uri uri = Uri.parse("path to pdf file");

    Intent intent = new Intent(context, MuPDFActivity.class);

    intent.setAction(Intent.ACTION_VIEW);

    intent.setData(uri);

    context.startActivity(intent);

Any suggestions on what might went wrong or missing? Any input will be largely appreciated.

UPDATE: i found out that, as the comment mentioned, mupdf was not started by any class. so i changed my code to trigger that class in the choosePDFActivity.java:

    @Override
protected void onListItemClick(ListView l, View v, int position, long id) {
    super.onListItemClick(l, v, position, id);

    mPositions.put(mDirectory.getAbsolutePath(), getListView().getFirstVisiblePosition());

    if (position < (mParent == null ? 0 : 1)) {
        mDirectory = mParent;
        mHandler.post(mUpdateFiles);
        return;
    }

    position -= (mParent == null ? 0 : 1);

    if (position < mDirs.length) {
        mDirectory = mDirs[position];
        mHandler.post(mUpdateFiles);
        return;
    }

    position -= mDirs.length;

    Uri uri = Uri.parse(mFiles[position].getAbsolutePath());
    Intent intent = new Intent(this,MuPDFActivity.class);
    intent.setAction(Intent.ACTION_VIEW);
    intent.setData(uri);
    startActivity(intent);
}

Now it opens Mupdf but got some errors:

06-12 10:31:51.875: W/dalvikvm(6551): Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing Ltys/app/test/MuPDFCore;

now when i click a pdf file it pops up an error messange. This is getting somewhere. Please help!

Community
  • 1
  • 1
BigGirl1017
  • 61
  • 1
  • 3
  • 12
  • Can you see any problems in the logcat as you try to view the PDF? – Intrications Jun 04 '14 at 17:22
  • let me paste the logcat into main question... – BigGirl1017 Jun 04 '14 at 17:51
  • There is nothing in the logcat about the MuPDFActivity so it doesn't really help. You should either add logging to MuPDFActivity or use breakpoints and debugging to check it is even starting. If it is, then you can try to work out why it can load the PDF. – Intrications Jun 04 '14 at 21:34
  • I found MuPDF library complicated to use may be this can help you http://stackoverflow.com/questions/24183472/how-to-open-pdf-in-android-using-pdfview – DCoder Jun 12 '14 at 13:49
  • @Intrications yes you'r right. I did what you suggested and found some errors about mupdfcore... – BigGirl1017 Jun 12 '14 at 17:33

1 Answers1

1

It looks like you haven't integrated MuPDF into your project correctly. MuPDF uses native code in order to accomplish its rendering, and that native code isn't getting included correctly - thus the UnsatisfiedLinkError in the logcat. Make sure you're including the right JNI binaries for the device you're testing on (ARM/ARMv7/x86 etc).

See also Android MuPDF Error

tophyr
  • 1,658
  • 14
  • 20