We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How do I get the current Vertical Offset of a WPF PdfViewer control

Thread ID:

Created:

Updated:

Platform:

Replies:

147619 Sep 17,2019 02:44 PM UTC Sep 25,2019 12:25 PM UTC WPF 7
loading
Tags: PdfViewer
Samuel Engelman
Asked On September 17, 2019 02:44 PM UTC

I tried getting a reference to the scrollviewer but the VerticalOffset is always 0

Aravindh Sathiyamoorthy [Syncfusion]
Replied On September 18, 2019 05:17 PM UTC

Hi Samuel, 

We can get the VerticalOffset from ScrollChanged event in PdfViewerControl. We have created a simple sample for the same and that can be downloaded from the below, 


Regards, 
Aravindh Sathiyamoorthy. 


Samuel
Replied On September 19, 2019 10:49 PM UTC

The number I get in the VerticalOffset of the event arguments do not match the number I put in to .ScrollTo
I also need to have access without handling the event.

Aravindh Sathiyamoorthy [Syncfusion]
Replied On September 20, 2019 01:46 PM UTC

Hi Samuel, 
 
Please find the details below, 
 
Query 
Details 
The number I get in the VerticalOffset of the event arguments do not match the number I put in to .ScrollTo 
We have modified the sample to achieve your requirement and that can be downloaded from the below link, 
 
 
Kindly use the above sample and let us know that meets your requirement or not. 
I also need to have access without handling the event. 
At present, we do not have support to get the VerticalOffset from PdfViewerControl directly. However, we will validate your requirement and provide you further details on 17th September 2019.  
 
 
Regards,
Aravindh Sathiyamoorthy.
 


Samuel
Replied On September 20, 2019 02:22 PM UTC

Try this example with adding the following line before the call to ScrollTo

pdfViewerControl.ZoomMode = Syncfusion.Windows.PdfViewer.ZoomMode.FitWidth;



Just to be clear what I'm trying to accomplish.
I'm trying to programmatically scroll one screen at a time (page down).

Aravindh Sathiyamoorthy [Syncfusion]
Replied On September 23, 2019 12:49 PM UTC

Hi Samuel, 
 
Please find the details below, 
 
Query 
Details 
Try this example with adding the following line before the call to ScrollTo 
 
pdfViewerControl.ZoomMode = Syncfusion.Windows.PdfViewer.ZoomMode.FitWidth; 
 
We can able to reproduce the issue “VerticalOffset is not same in ScrollChanged event if we applied ZoomMode in PdfViewerControl”. That was fixed in the sample itself. Please find the below link to get the modified sample, 
 
 
Please use the above sample and let us know whether it meets your requirement or not. If not, kindly share the following details to analyze more on this issue and assist you with the better solution  
1.       Simple sample/ modify the above sample with the issue PDF document to reproduce the issue. 
2.       Replication procedure to reproduce the issue. 
3.       Product version of PdfViewerControl that you have been using. 
 
I also need to have access without handling the event.  
We will implement the requirement of “Support to get the Vartical Offset from PdfViewerControl” by considering it as a usability feature. The patch for the same will be available on 7th October 2019.  
 
 
 
Regards, 
 
Aravindh Sathiyamoorthy. 



Pon Geetha A J [Syncfusion]
Replied On September 24, 2019 04:49 AM UTC

This is still not accurate 
 
 
This also relies on all pages being the same size. This isn’t always the case in PDF documents. 
 
I’m using the latest version of the controls. 
 
Here is the solution that seems to work for me: (PART_ScrollViewer seems to be the name of the scrollviewer that controls the actual page) 
Since you would have direct access to that scrollviewer, you really would only need the first method. 
 
        private static void ScrollPage(this PdfViewerControl pdf, bool pageDown) 
        { 
            var sv = pdf.FindVisualChild<ScrollViewer>("PART_ScrollViewer"); 
            sv.ScrollToVerticalOffset(sv.ContentVerticalOffset + (pageDown ? sv.ViewportHeight * .95 : -sv.ViewportHeight *.95)); 
        } 
 
        public static IEnumerable<T> FindVisualChildren<T>(this DependencyObject depObj) where T : DependencyObject 
        { 
            if (depObj != null) 
            { 
                for (int i = 0; i < VisualTreeHelper.GetChildrenCount(depObj); i++) 
                { 
                    DependencyObject child = VisualTreeHelper.GetChild(depObj, i); 
                    if (child != null && child is T) 
                    { 
                        yield return (T)child; 
                    } 
 
                    foreach (T childOfChild in FindVisualChildren<T>(child)) 
                    { 
                        yield return childOfChild; 
                    } 
                } 
            } 
        } 
        public static childItem FindVisualChild<childItem>(this DependencyObject obj, string name) where childItem : FrameworkElement 
        { 
            foreach (childItem child in FindVisualChildren<childItem>(obj)) 
            { 
                if (child.Name == name) return child; 
            } 
 
            return null; 
        } 


Aravindh Sathiyamoorthy [Syncfusion]
Replied On September 25, 2019 12:25 PM UTC

Hi Samuel,  
 
We are glad to know that the issue is resolved. Kindly get back to us if you need any further assistance. 
 
Regards, 
Aravindh Sathiyamoorthy. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon