Zoom to width / Zoom full page

5 posts, 0 answers
  1. David
    David avatar
    5 posts
    Member since:
    Sep 2008

    Posted 13 Mar 2012 Link to this post

    Hi there
    Is there anyway to set the zoom to 'Zoom to document width' or 'Zoom to Full Page view' - like the native Adobe Reader?

    If not, are there plans to implement these options?

    Thanks
    Dave
  2. Kammen
    Admin
    Kammen avatar
    312 posts

    Posted 14 Mar 2012 Link to this post

    Hi David,

    This kind of behavior is currently not supported. In some of the future versions we can implement it, but it has not been scheduled yet.

    However, in the upcoming service pack a DocumentChanged event will be introduced. With its help, you could achieve the effect of "zoom to document width" by setting the scale factor to a value calculated in the following way:

    double minWidth = this.viewer.Document.Pages.Min(p => p.Width);
    double k = (this.viewer.ActualWidth - 50 /* Some error like page margins, vertical scrollbar, etc. */) / minWidth;
    this.viewer.ScaleFactor = k;

    All the best,

    Kammen
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  3. DevCraft banner
  4. Ritwick
    Ritwick avatar
    11 posts
    Member since:
    Sep 2012

    Posted 05 Nov 2012 Link to this post

    Hi Kammen,

    The above mentioned code is not compilable. It says RadFixedPage doesnot contain definition for Width in "(p => p.Width)"

    Also, setting the scale factor to the pdf viewer directly or through binding doesn't work.

    Code snippet for correct usage will help.

    I am using Q3 2012 version with .NET 4.0.

    Thanks
    Ritwick
  5. Ritwick
    Ritwick avatar
    11 posts
    Member since:
    Sep 2012

    Posted 05 Nov 2012 Link to this post

    Hi Kammen,

    Solved the compilation issue, it should be ActualWidth instead of Width.

    But still do not know why the ScaleFactor setting works within DocumentChanged event but not elsewhere. For e.g. if ScaleFactor is set during initialization, it should get applied to the document when it is loaded. Besides, binding to ScaleFactor does not work.

    Thanks
    Ritwick
  6. Kammen
    Admin
    Kammen avatar
    312 posts

    Posted 05 Nov 2012 Link to this post

    Hello Ritwick,

    This is the behavior of the ScaleFactor property by design. We have decided that every time a new document is opened, the scale factor should be reset. That is why you cannot set the scale factor when initializing the document.

    On the other hand, if you handle the DocumentChanged event and set the property there, it will be used for the new document.

    Greetings,
    Kammen
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top
DevCraft banner