Knowledge Base - Vertical mode that fits to screen Height

Knowledge Base - Vertical mode that fits to screen Height

The default behavior of the vertical mode is to fit according to screen width.

If you want to make it fit to screen height instead, create a custom class that extends PDFLayoutVert as below (make sure to put it under package com.radaee.view, to be able to use all the protected properties).

 

public class VerticalFitHeight extends PDFLayoutVert {

public VerticalFitHeight(Context context) {
super(context);
}

@Override
public void vLayout() {
if(m_w <= 0 || m_h <= 0 || m_doc == null || m_pages == null) return;
int cnt = m_doc.GetPageCount();
int cur;
m_scale_min = ((float)(m_h - m_page_gap)) / m_page_maxh;
m_scale_max = m_scale_min * m_zoom_level;
if(m_scale < m_scale_min) m_scale = m_scale_min;
if(m_scale > m_scale_max) m_scale = m_scale_max;
boolean clip = m_scale / m_scale_min > m_zoom_level_clip;
m_tw = (int)(m_page_maxw * m_scale);
if( m_tw < m_w ) m_tw = m_w;
m_th = 0;
int y = m_page_gap>>1;
for(cur = 0;cur < cnt;cur++)
{
int w = (int)(m_doc.GetPageWidth(cur) * m_scale), cw = 0;
int h = (int)(m_doc.GetPageHeight(cur) * m_scale);
if (w + m_page_gap < m_w) cw = m_w;
else cw = (int) (w + m_page_gap * m_scale);
int x = Math.abs(cw - w) / 2;
m_pages[cur].vLayout(x, y, m_scale, clip);
y += h + m_page_gap;
}
m_th = y - (m_page_gap>>1);
}
}

 Note, you need to modify PDFLayoutView.PDFSetView to use your custom class instead of PDFLayoutVert

Applies To

RadaeePDF SDK for Android

Details

Created : 2017-10-26 09:10:50, Last Modified : 2017-10-26 09:13:48