Android pdf解析方案

最近在做一个健康类项目,要求用pdf展示体检报告,ios webview支持展示pdf,android的不支持,后来只能把pdf下载下来,再在程序中嵌入pdf查看,本来采用pdfViewer,但是发现有的pdf会报错,不稳定,上网搜了好久,也没有解决方案,后来换成了mupdf,按理说应该去github找star和fork最多的,说得好有道理的样子,我就是这样做的,然而还是没有解决,后来google到了一个帖子,说这个可以,下面进入正题,上链接:

https://github.com/geek5nan/AndroidMuPDFDemo

这个是可以解析pdf的但是项目要求pdf上下滑动翻页,但这个项目是左右滑动的,别着急,博主有办法:

将项目中onLayout2方法换成下面这个

protected void onLayout2(boolean changed, int left, int top, int right, int bottom) {
// super.onLayout(changed, left, top, right, bottom);


// "Edit mode" means when the View is being displayed in the Android GUI
// editor. (this class
// is instantiated in the IDE, so we need to be a bit careful what we
// do).
if (isInEditMode())
return;


View cv = mChildViews.get(mCurrent);
Point cvOffset;


if (!mResetLayout) {
// Move to next or previous if current is sufficiently off center
if (cv != null) {
cvOffset = subScreenSizeOffset(cv);
// cv.getRight() may be out of date with the current scale
// so add left to the measured width for the correct position
// if (cv.getLeft() + cv.getMeasuredWidth() + cvOffset.x + GAP/2
// + mXScroll < getWidth()/2 && mCurrent + 1 <
// mAdapter.getCount()) {
if (cv.getTop() + cv.getMeasuredHeight() + cvOffset.y + GAP / 2 + mYScroll < getHeight() / 2
&& mCurrent + 1 < mAdapter.getCount()) {
postUnsettle(cv);
// post to invoke test for end of animation
// where we must set hq area for the new current view
mStepper.prod();


onMoveOffChild(mCurrent);
mCurrent++;
onMoveToChild(mCurrent);
}


// if (cv.getLeft() - cvOffset.x - GAP/2 + mXScroll >=
// getWidth()/2 && mCurrent > 0) {
if (cv.getTop() - cvOffset.y - GAP / 2 + mYScroll >= getHeight() / 2 &a

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值