查看pdf

查看pdf

vudroid 这款不错 ,支持两点触碰放大缩小 支持跳转页面 解析的速度是我见过的几种类库的最快了 eoe有人给出过优化过的源码

https://blog.csdn.net/menglele1314/article/details/51177086

https://download.csdn.net/download/menglele1314/9494182

Android实现pdf在线预览或本地预览

博客http://blog.csdn.net/l598252892

https://download.csdn.net/download/u011430905/6216561

反编译别人封装的vudroid

下载地址

package org.vudroid.core;

public class VuDroidLibraryLoader
{
  private static boolean alreadyLoaded = false;

  public static void load()
  {
    if (alreadyLoaded)
    {
      return;
    }
    System.loadLibrary("vudroid");
    alreadyLoaded = true;
  }
}

包名:com.joanzapata.pdfview

发现更新项目

 https://github.com/JoanZapata/android-pdfview 这个项目是2年前的项目了,很久没维护了。//就是从csdn下载的原地址

You can find a good replacement here, which is a fork relying on Pdfium instead of Vudroid/MuPDF for decoding PDF files, allowing it to use the Apache License 2.0 which gives you much more freedom.

作者已经在GitHub的Readme里面做了说明:并且推荐了新的PDF开源库:https://github.com/barteksc/AndroidPdfViewer

使用barteksc新的pdf库

github

compile ‘com.github.barteksc:android-pdf-viewer:3.1.0-beta.1’

报错:Could not determine artifacts for com.android.support:support-compat:26.1.0
对应最新的github的源码,
//库
dependencies {
    implementation 'com.android.support:support-compat:26.1.0'
    api 'com.github.barteksc:pdfium-android:1.9.0'
}
//demo
dependencies {
    classpath 'com.android.tools.build:gradle:3.1.3'
    classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.1'
    classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
}
会去查最新的gradle,不一定维护正常

compile ‘com.github.barteksc:android-pdf-viewer:2.8.2’

报错:Could not determine artifacts for com.github.barteksc:pdfium-android:1.7.1
Could not get resource 'http://jcenter.bintray.com/com/github/barteksc/pdfium-android/1.7.1/pdfium-android-1.7.1.aar'.
Could not HEAD 'http://jcenter.bintray.com/com/github/barteksc/pdfium-android/1.7.1/pdfium-android-1.7.1.aar'.

去网址http://jcenter.bintray.com/com/github/barteksc/pdfium-android/下查询确实下载不了

修改为implementation ‘com.github.barteksc:android-pdf-viewer:2.8.1’ 成功下载

但是最新的demo不能使用。

找到2.8.0的文章

或者查看2.8.1的tag

import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.NonConfigurationInstance;
import org.androidannotations.annotations.OnActivityResult;
import org.androidannotations.annotations.OptionsItem;
import org.androidannotations.annotations.OptionsMenu;
import org.androidannotations.annotations.ViewById;

无法使用AndroidAnnotations注释

加载文档关键代码

@Override
protected Throwable doInBackground(Void... params) {
    try {
        pdfDocument = docSource.createDocument(context, pdfiumCore, password);
        // We assume all the pages are the same size
        pdfiumCore.openPage(pdfDocument, firstPageIdx);
        pageWidth = pdfiumCore.getPageWidth(pdfDocument, firstPageIdx);
        pageHeight = pdfiumCore.getPageHeight(pdfDocument, firstPageIdx);
        return null;
    } catch (Throwable t) {
        return t;
    }
}

AndroidAnnotations注释框架

AndroidAnnotations开发框架使用详解
@AfterViews

表示在组件初始化完成后在执行,更新组件状态的方法必须加上这个注解,否则会出现空指针。

注意:添加@EActivity(R.layout.XXX)的时候如果没有删除onCreate(Bundle savedInstanceState)中的layout配置,activity会进行两次布局,导致执行两次配置@AfterViews注解的方法。

MuPDF

MuPDF

doc

开源 Android pdf 阅读器开发总结

前段时间项目涉及到pdf阅读,因此我开始找了些源码阅读比较,现在贴出各实现方案的对比。希望对大家有帮助。方便大家的阅读,我将自己认为最好的排在最前。

    Vudroid

    Google code:http://code.google.com/p/vudroid/

    这是一款可以阅读pdf和djvu格式文本的阅读器。按道理说我使用这个给自己带来一定的麻烦,因为我自己需要剥离pdf部分,因为作者底层用的ndk开发,我还得重新编译so库。但是,在我找到的所有源代码中,此作品是最顺畅的,我不能割舍。如果大家想要快速使用而不想剥离pdf部分,可以使用我的google code:http://code-ernest.googlecode.com/svn/trunk/DocumentViewer

   	droidReader

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

    其采用native library和Vudroid一样:MuPDF

    但是它的缺点是,实现上比Vudroid少了那么点顺畅性,在zoom这一点上要输Vudroid,其他方面都很棒。

    apv

    Google code:http://code.google.com/p/apv/

    其采用native library和Vudroid一样:MuPDF

    理论上来说应该和Vudroid不太差,它的问题是刷新比Vudroid要慢那么一点,没有多点触控。但是,有一点必须说的是:Vudroid读取文本格式的超强,我给过20M的文字版的pdf测试过,vudroid都能顺畅阅读,Vudroid读取扫描版的或者里面有图片的要差一点,速度稍慢;而apv读取扫描版的则顺畅一点,50M的扫描版也没有问题,但是,20M的文字版pdf它不能读,我没有深究什么原因,大家有兴趣的可以发现下,望指教:ernest.he2009@gmail.com

            apdfviewer

        Google code: http://code.google.com/p/apdfviewer/

    代码最少,整页加载模式中最快的一款,当然,快,就意味着有可能是ndk开发,不错它就是ndk的产物,有兴趣的可以使用。注意:大文件读取有点慢,我以为它死了。这一点上最好的是Vudroid。

    另外还有一款是基于Sun的pdf解析库的,纯java,唯一一款纯java的。但是,它的致命之处是,他读不了大文件。Oh no。可以从eoeAndroid论坛获取。

    还有许多你可以从Google code上获取到许多类似的。如果你有更好的发现,联系我:ernest.he2009@gmail.com

Invalid ZIP archive: libs/armeabi/libvudroid.so [in DocumentViewer]
在Eclipse Project Properties-> Java Build Path -> Library中删除libvudroid.so即可。

其他

Android开源项目总结

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值