繁体   English   中英

如何使用pdfview在android中打开PDF

[英]how to open PDF in android using pdfview

我正在使用android-pdfview-1.0.2.jar我在这里找到它链接到主项目在这里我试图加载PDF如下

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

我在我的布局中添加了pdfView,如下所示

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

执行时我收到以下错误:

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

通过添加armeabi-v7a文件夹解决了问题,可在此处找到

现在sample.pdf看起来像 在此输入图像描述

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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