本文介绍了如何在使用pdfview Android开放PDF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的Andr​​oid pdfview-1.0.2.jar我发现它的链接到主项目是这里我想加载PDF如下:

  PDFView pdfView =(PDFView)findViewById(R.id.pdfView);
pdfView.fromAsset(sample.pdf)
.defaultPage(1)
.showMinimap(假)
.enableSwipe(真)
.onLoad(本)
.onPageChange(本)
。加载();
 

我在我的布局添加pdfView如下图

 <的FrameLayout的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
的xmlns:工具=htt​​p://schemas.android.com/tool​​s
机器人:layout_width =match_parent
机器人:layout_height =match_parent>

    < com.joanzapata.pdfview.PDFView
        机器人:ID =@ + ID / pdfView
        机器人:layout_width =match_parent
        机器人:layout_height =match_parent/>

< /的FrameLayout>
 

在执行我收到以下错误:

  06-12 17:10:10.015:E / AndroidRuntime(21726):致命异常:AsyncTask的#1
06-12 17:10:10.015:E / AndroidRuntime(21726):java.lang.RuntimeException的:执行doInBackground时出错()
06-12 17:10:10.015:E / AndroidRuntime(21726):在android.os.AsyncTask $ 3.done(AsyncTask.java:299)
06-12 17:10:10.015:E / AndroidRuntime(21726):在java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:352)
06-12 17:10:10.015:E / AndroidRuntime(21726):在java.util.concurrent.FutureTask.setException(FutureTask.java:219)
06-12 17:10:10.015:E / AndroidRuntime(21726):在java.util.concurrent.FutureTask.run(FutureTask.java:239)
06-12 17:10:10.015:E / AndroidRuntime(21726):在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
06-12 17:10:10.015:E / AndroidRuntime(21726):在java.util.concurrent.ThreadPoolExecutor中的$ Worker.run(ThreadPoolExecutor.java:573)
06-12 17:10:10.015:E / AndroidRuntime(21726):在java.lang.Thread.run(Thread.java:838)
06-12 17:10:10.015:E / AndroidRuntime(21726):java.lang.UnsatisfiedLinkError中:产生的原因无法从加载器加载vudroid dalvik.system.PathClassLoader [DexPathList [zip文件"/data/app/com.klouddata.pdffileexample-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.klouddata.pdffileexample-2, /供应商/ lib中/系统/ lib目录]]]:findLibrary返回null
06-12 17:10:10.015:E / AndroidRuntime(21726):在java.lang.Runtime.loadLibrary(Runtime.java:359)
06-12 17:10:10.015:E / AndroidRuntime(21726):在java.lang.System.loadLibrary(System.java:514)
06-12 17:10:10.015:E / AndroidRuntime(21726):在org.vudroid.core.VuDroidLibraryLoader.load(VuDroidLibraryLoader.java:13)
06-12 17:10:10.015:E / AndroidRuntime(21726):在org.vudroid.pdfdroid codec.PdfContext< clinit>(PdfContext.java:13)
06-12 17:10:10.015:E / AndroidRuntime(21726):在com.joanzapata.pdfview.DecodingAsyncTask.doInBackground(DecodingAsyncTask.java:50)
06-12 17:10:10.015:E / AndroidRuntime(21726):在com.joanzapata.pdfview.DecodingAsyncTask.doInBackground(DecodingAsyncTask.java:31)
06-12 17:10:10.015:E / AndroidRuntime(21726):在android.os.AsyncTask $ 2.call(AsyncTask.java:287)
06-12 17:10:10.015:E / AndroidRuntime(21726):在java.util.concurrent.FutureTask.run(FutureTask.java:234)
06-12 17:10:10.015:E / AndroidRuntime(21726):... 3更多
 

解决方案

加入armeabi-V7A文件夹解决问题,这都可以找到的

现在sample.pdf的样子

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
解决方案

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

now sample.pdf looks like

这篇关于如何在使用pdfview Android开放PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 21:44