BigGirl1017
BigGirl1017

Reputation: 61

MuPDF renders empty pdf file in Android app

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!

Upvotes: 1

Views: 813

Answers (1)

tophyr
tophyr

Reputation: 1678

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

Upvotes: 1

Related Questions