Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
210 views
in Technique[技术] by (71.8m points)

java - how to open PDF in android using pdfview

I am using android-pdfview-1.0.2.jar I found it here Link to the main project is here I am trying to load PDF as follows

PDFView pdfView= (PDFView) findViewById(R.id.pdfView);
pdfView.fromAsset("sample.pdf")
.defaultPage(1)
.showMinimap(false)
.enableSwipe(true)
.onLoad(this)
.onPageChange(this)
.load();

I have added pdfView in my layout as shown below

    <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >

    <com.joanzapata.pdfview.PDFView
        android:id="@+id/pdfView"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

</FrameLayout>

while executing I am getting following error:

06-12 17:10:10.015: E/AndroidRuntime(21726): FATAL EXCEPTION: AsyncTask #1
06-12 17:10:10.015: E/AndroidRuntime(21726): java.lang.RuntimeException: An error occured while executing doInBackground()
06-12 17:10:10.015: E/AndroidRuntime(21726):    at android.os.AsyncTask$3.done(AsyncTask.java:299)
06-12 17:10:10.015: E/AndroidRuntime(21726):    at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:352)
06-12 17:10:10.015: E/AndroidRuntime(21726):    at java.util.concurrent.FutureTask.setException(FutureTask.java:219)
06-12 17:10:10.015: E/AndroidRuntime(21726):    at java.util.concurrent.FutureTask.run(FutureTask.java:239)
06-12 17:10:10.015: E/AndroidRuntime(21726):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
06-12 17:10:10.015: E/AndroidRuntime(21726):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
06-12 17:10:10.015: E/AndroidRuntime(21726):    at java.lang.Thread.run(Thread.java:838)
06-12 17:10:10.015: E/AndroidRuntime(21726): Caused by: java.lang.UnsatisfiedLinkError: Couldn't load vudroid from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.klouddata.pdffileexample-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.klouddata.pdffileexample-2, /vendor/lib, /system/lib]]]: findLibrary returned null
06-12 17:10:10.015: E/AndroidRuntime(21726):    at java.lang.Runtime.loadLibrary(Runtime.java:359)
06-12 17:10:10.015: E/AndroidRuntime(21726):    at java.lang.System.loadLibrary(System.java:514)
06-12 17:10:10.015: E/AndroidRuntime(21726):    at org.vudroid.core.VuDroidLibraryLoader.load(VuDroidLibraryLoader.java:13)
06-12 17:10:10.015: E/AndroidRuntime(21726):    at org.vudroid.pdfdroid.codec.PdfContext.<clinit>(PdfContext.java:13)
06-12 17:10:10.015: E/AndroidRuntime(21726):    at com.joanzapata.pdfview.DecodingAsyncTask.doInBackground(DecodingAsyncTask.java:50)
06-12 17:10:10.015: E/AndroidRuntime(21726):    at com.joanzapata.pdfview.DecodingAsyncTask.doInBackground(DecodingAsyncTask.java:31)
06-12 17:10:10.015: E/AndroidRuntime(21726):    at android.os.AsyncTask$2.call(AsyncTask.java:287)
06-12 17:10:10.015: E/AndroidRuntime(21726):    at java.util.concurrent.FutureTask.run(FutureTask.java:234)
06-12 17:10:10.015: E/AndroidRuntime(21726):    ... 3 more
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Solved problem by adding armeabi-v7a folder which can be found here

now sample.pdf looks like enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...