FIT To SCreen - Page 3 - RadaeePDF.com - Results from #12
Signin/Signup with: 
Welcome, Guest
Username: Password: Remember me
Questions about Android development and PDF

TOPIC: FIT To SCreen

FIT To SCreen 5 years 5 months ago #5023

  • SONAWANE
  • SONAWANE's Avatar
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 7
  • Thank you received: 0
Just change onSizeChanged from PDFReader to below code. This will scale vertical PDF to fit screen height. If PDF height is high than screen size try to change
m_view.vSetScale((m_view.vGetMaxScale() / 2), 0, 0);
according to your need.

@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {

super.onSizeChanged(w, h, oldw, oldh);
if (m_view == null)
return;
PDFPos pos = m_view.vGetPos(w / 2, h / 2);
m_view.vResize(w, h);
float max_w = m_doc.GetPageWidth(0);
float max_h = m_doc.GetPageHeight(0);
int page = 1;
int pages_cnt = m_doc.GetPageCount();
while (page < pages_cnt) {
float doc_w = m_doc.GetPageWidth(page);
float doc_h = m_doc.GetPageHeight(page);
if (max_w < doc_w)
max_w = doc_w;
if (max_h < doc_h)
max_h = doc_h;
page++;
}
if ((max_w > max_h || ((Activity) context).getResources()
.getConfiguration().orientation == ((Activity) context)
.getResources().getConfiguration().ORIENTATION_LANDSCAPE)
&& (max_w > w || ((Activity) context).getResources()
.getConfiguration().orientation == ((Activity) context)
.getResources().getConfiguration().ORIENTATION_LANDSCAPE))
m_view.vSetScale(0, 0, 0);
else
m_view.vSetScale((m_view.vGetMaxScale() / 2), 0, 0);// fit page
// while
// resizing.
// m_view.vSetScale(0, 0, 0);// fit page while resizing.
if (m_goto_pageno >= 0) {
m_view.vGotoPage(m_goto_pageno);
m_goto_pageno = -1;
} else if (pos != null) {
m_view.vSetPos(pos, w / 2, h / 2);
// m_view.vCenterPage(pos.pageno);
}
if (m_scale >= 0) {
m_view.vSetScale(m_scale, 0, 0);
m_scale = -1;
}

/*
* super.onSizeChanged(w, h, oldw, oldh); if (m_view == null) return;
* PDFPos pos = m_view.vGetPos(w / 2, h / 2); m_view.vResize(w, h);
* m_view.vSetScale((m_view.vGetMaxScale()/2), 0, 0);// fit page while
* resizing. if (m_goto_pageno >= 0) { m_view.vGotoPage(m_goto_pageno);
* m_goto_pageno = -1; } else if (pos != null) { m_view.vSetPos(pos, w /
* 2, h / 2); // m_view.vCenterPage(pos.pageno); } if (m_scale >= 0) {
* m_view.vSetScale(m_scale, 0, 0); m_scale = -1; }
*/
}
The following user(s) said Thank You: marcoP
The topic has been locked.
Powered by Kunena Forum