- Posts: 7
- Thank you received: 0
Microsoft Windows Phone 8.1 support ends (13 Jul 2017)
Microsoft has ended support for Windows Phone 8.1
Questions about Windows 8.1, 10, WindowsPhone, Windows UWP
Can I fit the view to page on first render?
11 years 1 day ago #8661
by coderox
Can I fit the view to page on first render? was created by coderox
I'm trying to fit the Reading experience when the document is first opened to fit the width of the actual device (the rendering canvas) but the content is Always rendered in a scale mode which is 1.0 (as I see it) with the actual width of the document being used instead of the device width. This means the user Always has to begin by zooming out the document which is a bad experience.
I've tried to examine the properites available regarding width and height but it puzzles me that these are occassionally zeroed which means they can't be used with confidence.
This is for a Universal Windows and Windows Phone XAML app.
Please advise
Johan Lindfors
// coderox
I've tried to examine the properites available regarding width and height but it puzzles me that these are occassionally zeroed which means they can't be used with confidence.
This is for a Universal Windows and Windows Phone XAML app.
Please advise
Johan Lindfors
// coderox
11 years 1 day ago #8663
by igokul
Replied by igokul on topic Can I fit the view to page on first render?
Trying to solve exactly the same problem, the code is a real mess. I somehow managed to fit it vertically on the phone by changing the magic constant 600 to parent.ActualHeight in PDFViewVert and it kind of works, most of the times.
But we definitely need a real solution, to fit the PDF on both phone and tablet in all the three modes. I hope someone from Radaee would respond ...
But we definitely need a real solution, to fit the PDF on both phone and tablet in all the three modes. I hope someone from Radaee would respond ...
11 years 1 day ago - 11 years 1 day ago #8671
by Gooren
Replied by Gooren on topic Can I fit the view to page on first render?
Hello, i believe i MAY have a solution for you. In our application, we needed pdf pages to fit on height when working in horizontal mode. In this scenario we used PdfViewHorz class as a view class and i modified it's vLayout method like this:
For us, this works perfectly. I hope i helped:)
Sincerely, Steven
Code:
if (m_doc == null || m_w <= m_page_gap || m_h <= m_page_gap) return;
float minScale = 1.0f;
float maxScale = minScale * zoomLevel;
m_scroller.MinZoomFactor = minScale;
m_scroller.MaxZoomFactor = maxScale;
ZoomEnd();
m_scroller.Width = m_w;
m_scroller.Height = m_h;
if (m_pages != null) return;
int cur = 0;
int cnt = m_doc.PageCount;
float maxh = 0;
while (cur < cnt)
{
float h = m_doc.GetPageHeight(cur);
if (maxh < h) maxh = h;
cur++;
}
float scale = ((float)(m_h - m_page_gap)) / maxh;
if (scale < minScale)
scale = minScale;
else if (scale > maxScale)
scale = maxScale;
m_scale = scale;
m_pages = new PDFVPage[cnt];
float left = m_page_gap / 2;
float top = m_page_gap / 2;
m_docw = 0;
m_doch = 0;
if (m_rtol)
{
cur = cnt - 1;
while (cur >= 0)
{
m_pages[cur] = new PDFVPage(m_doc, cur);
m_pages[cur].SetRect(m_layout, left, top, m_scale);
left += m_pages[cur].GetWidth() + m_page_gap;
if (m_doch < m_pages[cur].GetHeight()) m_doch = m_pages[cur].GetHeight();
cur--;
}
}
else
{
cur = 0;
while (cur < cnt)
{
m_pages[cur] = new PDFVPage(m_doc, cur);
m_pages[cur].SetRect(m_layout, left, top, m_scale);
left += m_pages[cur].GetWidth() + m_page_gap;
if (m_doch < m_pages[cur].GetHeight()) m_doch = m_pages[cur].GetHeight();
cur++;
}
}
m_docw = left;
m_doch += m_page_gap;
m_layout.resize(m_docw, m_doch);
m_scroller.UpdateLayout();
For us, this works perfectly. I hope i helped:)
Sincerely, Steven
Last edit: 11 years 1 day ago by Gooren.
11 years 1 day ago #8673
by igokul
Replied by igokul on topic Can I fit the view to page on first render?
I do not see any change, the pages are still kind of fit to height, I need to fit them to width on horizontal mode so only a page is visible as whole on the phone screen.
11 years 1 day ago - 11 years 1 day ago #8674
by Gooren
Replied by Gooren on topic Can I fit the view to page on first render?
I misunderstood your problem then. If you wish to fill the screen with one page in horizontal view... well... i don't think it will be easy. What about showing two pages at once in horizontal view? Radaee is trying to preserve page's aspect ratio at all costs. You will have to hack it a bit more in order to force it to resize the page to parent control bounds and reflow it's content. And since it seems that WinRT, unlike Android version, doesn't have reflow feature implemented yet. You can't do much about it. They will try to rescale it otherwise. Enjoy bro:D
Last edit: 11 years 1 day ago by Gooren.
11 years 1 day ago - 11 years 1 day ago #8675
by igokul
Replied by igokul on topic Can I fit the view to page on first render?
Here is what I want
Phone - Portrait
PDVViewVert - fit the width, this should not be hard to do, but the sample could is just plain undreadable
PDFViewHorz - fit the width, make margins on top and bottom so the page has the same width ad the phone width
Phone - Portrait
PDVViewVert - fit the width, this should not be hard to do, but the sample could is just plain undreadable
PDFViewHorz - fit the width, make margins on top and bottom so the page has the same width ad the phone width
Last edit: 11 years 1 day ago by igokul.
Time to create page: 0.445 seconds