Siva Bharata Siva Bharata - 11 months ago 141
Android Question

MuPDF Android Pdf fit to the screen

I succesfully installed MuPDF for one of my Android Apps. But the problems is, while rendering I cannot fit the PDF to the screen. Can anybody please suggest me how to achieve this. Thanks!


Edit the measureView method in to become.

private void measureView(View v) {
        // See what size the view wants to be
        v.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
        // Work out a scale that will fit it to this view
        float scale;
        if (getWidth()>getHeight())
            scale = (float)getWidth()/(float)v.getMeasuredWidth();
            MIN_SCALE = (float)v.getMeasuredWidth()/(float)getWidth();
            MAX_SCALE = MIN_SCALE*5.0f;
            scale = Math.min((float)getWidth()/(float)v.getMeasuredWidth(),

        // Use the fitting values scaled by our current scale factor
        v.measure(View.MeasureSpec.EXACTLY | (int)(v.getMeasuredWidth()*scale*mScale),
                View.MeasureSpec.EXACTLY | (int)(v.getMeasuredHeight()*scale*mScale));