【问题标题】:how to open PDF in android using pdfview如何使用pdfview在android中打开PDF
【发布时间】:2014-06-12 11:42:47
【问题描述】:

我正在使用 android-pdfview-1.0.2.jar 我发现它here 到主项目的链接是here 我正在尝试按如下方式加载 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

【问题讨论】:

  • 你的异步任务代码在哪里?
  • 我的代码中没有任何异步任务
  • 它在您的异常中显示 FATAL EXCEPTION: AsyncTaskjava.lang.RuntimeException: An error occured while executing doInBackground()
  • 是的,我可以看到。但相信我,我没有使用过异步任务
  • 堆栈跟踪的重要部分是` 引起: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]]]`

标签: java android


【解决方案1】:

通过添加 armeabi-v7a 文件夹解决问题,该文件夹可在here 找到

现在 sample.pdf 看起来像

【讨论】:

  • 嗨@DCoder,您在显示pdf时遇到过它总是水平的吗?你是怎么解决的?谢谢。
  • 您是否将文件夹复制粘贴到您的库目录?还是 .so 文件本身?
猜你喜欢
  • 1970-01-01
  • 2012-05-15
  • 1970-01-01
  • 2020-02-26
  • 2020-06-01
  • 2012-11-03
  • 2015-07-14
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多