Can I fit the view to page on first render? - RadaeePDF.com
Signin/Signup with: 
Welcome, Guest
Username: Password: Remember me
13 Jul 2017
Microsoft has ended support for Windows Phone 8.1
Read More...
Questions about Windows 8.1, 10, WindowsPhone, Windows UWP
  • Page:
  • 1
  • 2

TOPIC: Can I fit the view to page on first render?

Can I fit the view to page on first render? 3 years 8 months ago #8661

  • coderox
  • coderox's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 7
  • Thank you received: 0
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

Please Log in or Create an account to join the conversation.

Can I fit the view to page on first render? 3 years 8 months ago #8663

  • igokul
  • igokul's Avatar
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 4
  • Thank you received: 0
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 ...

Please Log in or Create an account to join the conversation.

Can I fit the view to page on first render? 3 years 8 months ago #8671

  • Gooren
  • Gooren's Avatar
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 6
  • Thank you received: 0
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:
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

Please Log in or Create an account to join the conversation.

Last edit: by Gooren.

Can I fit the view to page on first render? 3 years 8 months ago #8673

  • igokul
  • igokul's Avatar
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 4
  • Thank you received: 0
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.

Please Log in or Create an account to join the conversation.

Can I fit the view to page on first render? 3 years 8 months ago #8674

  • Gooren
  • Gooren's Avatar
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 6
  • Thank you received: 0
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

Please Log in or Create an account to join the conversation.

Last edit: by Gooren.

Can I fit the view to page on first render? 3 years 8 months ago #8675

  • igokul
  • igokul's Avatar
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 4
  • Thank you received: 0
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

Please Log in or Create an account to join the conversation.

Last edit: by igokul.
  • Page:
  • 1
  • 2
Powered by Kunena Forum