zoom with scroll

3 posts, 0 answers
  1. Davide
    Davide avatar
    5 posts
    Member since:
    Mar 2016

    Posted 06 Apr 2016 Link to this post


    can the pdfviewer automatically scroll in the position where the user is zooming with the fingers?

    because if i zoom in a specific position (for example bottom right), the pdfviewer continues to zoom in top left angle of the pdf.




  2. Davide
    Davide avatar
    5 posts
    Member since:
    Mar 2016

    Posted 08 Apr 2016 Link to this post

  3. Deyan
    Deyan avatar
    157 posts

    Posted 11 Apr 2016 Link to this post

    Hi Davide,

    Thank you for contacting us.

    This functionality is not available in the current version of the product. You may vote for the feature request and follow its implementation progress by following the feedback item.

    Meanwhile, you may try to workaround this missing functionality by using Telerik TouchManager, RadPdfViewer's GoToDestination method, HorizontalScrollBar and VerticalScrollBar properties. Currently, RadPdfViewer uses TouchManager Pinch events to zoom, so if you attach to the corresponding events you may try scrolling to the correct position right after RadPdfViewer has performed its default zoom behaviour. Here follow a few hints that may help you to implement this functionality:
    • First thing you need to do is to attach to RadPdfViewer's FixedDocumentPresenterChanged, so that you can attach to the new presenter touch event and detach from the same events of the old presenter.
    • In order to be notified when the zoom action is performed you should use TouchManager methods AddPinchStartedEventHandler, AddPinchEventHandler and AddPinchFinishedEventHandler. This methods will add your custom event handlers to RadPdfViewer's FixedDocumentPresenter. The last parameter of these methods should be "true" as you need to handle already handled events.
    • By using PinchEventArgs GetTouchPoint1 and GetTouchPoint2 methods you may get the pinch points relative to the presenter. Getting the mid point of the above two points you will get the point in the viewport that should preserve its position after zooming.
    • By using FixedDocumentPresenter's GetLocationFromViewPoint method you may convert the viewport position of the pinch point to PDF document position. This way you will know exactly which page is zoomed and which point in this page should preserve its viewport position. In your PinchStartedEventHandler you may additionally get the ScaleFactor value at the moment the zoom action starts.
    • You may preserve the above information for RadFixedPage, Left and Top page coordinates and the current Zoom value in a Location class instance.
    • In PinchEventHandler and PinchFinishedEventHandler you may use RadPdfViewer's GoToDestination method in order to scroll to the previosly preserved Location. You should be aware that GoToDestination method scrolls such that the Location point is positioned at the top left viewport corner. In order to move this document point to the desired position you should perform some additional scrolling using RadPdfViewer's HorizontalScrollBar and VerticalScrollBar properties. In order to calculate how much exactly you need to scroll you should use the current ScaleFactor value and RadFixedPage instances Size property. You should also be aware that if the active presenter is FixedDocumentPagesPresenter then there is additional vertical gap between each two neighbouring pages. This gap has constant value and its value is 10.
    • If you follow this link to a forum post you may see a similar example showing how to attach to FixedDocumentPresenter viewport events and how to use GetLocationFromViewPoint and GoToDestination methods in order to scroll to previously clicked position.

    I hope this helps. If you have any other questions or concerns please do not hesitate to contact us again.

    the Telerik team
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Back to Top