navigating to a specific page with the mupdf android library

后端 未结 2 1240
野的像风
野的像风 2021-01-22 15:58

How would I go about navigating to a specific page with the muPDF library? Or is there a way to make the library not remember which page I was last on in that pdf?



        
2条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-22 17:04

    package com.artifex.mupdf;
    
    import android.content.Context;
    import android.graphics.Bitmap;
    import android.graphics.Point;
    import android.util.Log;
    
    public class MuPDFPageView extends PageView {
        private final MuPDFCore mCore;
    
        public MuPDFPageView(Context c, MuPDFCore core, Point parentSize) {
            super(c, parentSize);
            mCore = core;
        }
    
        public String hitLinkPage(float x, float y) {
            // Since link highlighting was implemented, the super class
            // PageView has had sufficient information to be able to
            // perform this method directly. Making that change would
            // make MuPDFCore.hitLinkPage superfluous.
            float scale = mSourceScale * getWidth() / mSize.x ;
    
    
            float docRelX = (x - getLeft()) / scale;
            float docRelY = (y - getTop()) / scale;
               Log.d("Page Number", "hitLinkPage with page = " + mCore.hitLinkPage(mPageNumber, docRelX, docRelY));
            return mCore.hitLinkPage(mPageNumber, docRelX, docRelY);
        }
    
        @Override
        protected void drawPage(Bitmap bm, int sizeX, int sizeY, int patchX,
                int patchY, int patchWidth, int patchHeight) {
            mCore.drawPage(mPageNumber, bm, sizeX, sizeY, patchX, patchY,
                    patchWidth, patchHeight);
        }
    
        @Override
        protected LinkInfo[] getLinkInfo() {
            return mCore.getPageLinks(mPageNumber);
        }
    }
    

提交回复
热议问题