简体   繁体   中英

error in android pdf view library

i need to use an open source pdf view in my project and i used the android pdf view library . i have added the jar file to build path and when i run my project i get some error . there is my code :

public class MainActivity extends Activity {

    private int CODE;
    private String PATH;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Button b2 = (Button) findViewById(R.id.button2);
        CODE = 1;
        Button b = (Button) findViewById(R.id.button1);
        b.setOnClickListener(new OnClickListener() {

            public void onClick(View arg0) {

                Intent in = new Intent(MainActivity.this, pdfAct.class);
                in.putExtra(PdfViewerActivity.EXTRA_PDFFILENAME, PATH);
                startActivity(in);
            }
        });

        b2.setOnClickListener(new OnClickListener() {

            public void onClick(View arg0) {

                Intent i = new Intent(Intent.ACTION_GET_CONTENT);
                i.setType("*/*");
                startActivityForResult(i, CODE);

            }
        });

    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        PATH = data.getDataString();

    }

}

pdf view activity :

import net.sf.andpdf.pdfviewer.PdfViewerActivity;

public class pdfAct extends PdfViewerActivity {

    @Override
    public int getNextPageImageResource() {
        return R.drawable.right_arrow;
    }

    @Override
    public int getPdfPageNumberEditField() {
        return R.id.pagenum_edit;
    }

    @Override
    public int getPdfPageNumberResource() {
        return R.layout.dialog_pagenumber;
    }

    @Override
    public int getPdfPasswordEditField() {
        return R.id.etPassword;
    }

    @Override
    public int getPdfPasswordExitButton() {
        return R.id.btExit;
    }

    @Override
    public int getPdfPasswordLayoutResource() {
        return R.layout.pdf_file_password;
    }

    @Override
    public int getPdfPasswordOkButton() {
        return R.id.btOK;
    }

    @Override
    public int getPreviousPageImageResource() {
        return R.drawable.left_arrow;
    }

    @Override
    public int getZoomInImageResource() {
        return R.drawable.zoom_in;
    }

    @Override
    public int getZoomOutImageResource() {
        return R.drawable.zoom_out;
    }

}

and log file for error :

10-30 08:23:18.991: E/AndroidRuntime(1613): FATAL EXCEPTION: main
10-30 08:23:18.991: E/AndroidRuntime(1613): java.lang.NoClassDefFoundError: com.example.pdf01.pdfAct
10-30 08:23:18.991: E/AndroidRuntime(1613):     at com.example.pdf01.MainActivity$1.onClick(MainActivity.java:27)
10-30 08:23:18.991: E/AndroidRuntime(1613):     at android.view.View.performClick(View.java:4204)
10-30 08:23:18.991: E/AndroidRuntime(1613):     at android.view.View$PerformClick.run(View.java:17355)
10-30 08:23:18.991: E/AndroidRuntime(1613):     at android.os.Handler.handleCallback(Handler.java:725)
10-30 08:23:18.991: E/AndroidRuntime(1613):     at android.os.Handler.dispatchMessage(Handler.java:92)
10-30 08:23:18.991: E/AndroidRuntime(1613):     at android.os.Looper.loop(Looper.java:137)
10-30 08:23:18.991: E/AndroidRuntime(1613):     at android.app.ActivityThread.main(ActivityThread.java:5041)
10-30 08:23:18.991: E/AndroidRuntime(1613):     at java.lang.reflect.Method.invokeNative(Native Method)
10-30 08:23:18.991: E/AndroidRuntime(1613):     at java.lang.reflect.Method.invoke(Method.java:511)
10-30 08:23:18.991: E/AndroidRuntime(1613):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
10-30 08:23:18.991: E/AndroidRuntime(1613):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
10-30 08:23:18.991: E/AndroidRuntime(1613):     at dalvik.system.NativeStart.main(Native Method)

I would suggest you to use mu-pdf library.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).

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

GITHUB --> https://github.com/muennich/mupdf

take note that is not free for commercial apps –

check this for better help --> Integrate MuPDF Reader in an app


update

Some of the source code files for PDF viewer in Android application. Check the links and try it:

http://code.google.com/p/apv/source/browse/

http://code.google.com/p/android-pdf/

http://code.google.com/p/droidreader/

http://andpdf.sourceforge.net/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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