ScrollTo complimentary function

Hello

i have one question about the function of scrolling to every point of the document. I found this thread ScrollTo Function and try to build an complimentary function for the wpf viewer.

`

_viewer.ConvPagePtToScreenPt(ref x, ref y,page_numb);
_viewer.SetHScrollPos(x);
_viewer.SetVScrollPos(y);

`

The problem is that the viewer is not scrolling to the right position so what is the mistake in my reflection?

Thanks
Daniel

Hi Daniel,

I’m assuming you got the x and y positions from some object on page number page_num.
The first thing to look at is the scroll position. x and y after converting is in screen space, while SetX/YScrollPos is in the coordinates of the scroll viewer. That is, the top left corner of the PDFViewCtrl is at position (0, 0) in screen space, but at position (GetHScrollPos and GetVScrollPos) in scroll coordinates. I would suggest trying

_viewer.SetHScrollPois(x + _view.GetHScrollPos());
_viewer.SetVScrollPois(y + _view.GetVScrollPos());

If that does not work, could you elaborate a little more on what you are doing?

Best Regards,
Tomas Hofmann

Hello Thomas,

thank you for your reply. You answer is so easy and works fine. Now i can jump to every point on every side. Thank you very much.

Best regards
Daniel
Am Montag, 10. Februar 2014 12:39:50 UTC+1 schrieb Daniel Lutz:

Hello

i have one question about the function of scrolling to every point of the document. I found this thread ScrollTo Function and try to build an complimentary function for the wpf viewer.

`

_viewer.ConvPagePtToScreenPt(ref x, ref y,page_numb);
_viewer.SetHScrollPos(x);
_viewer.SetVScrollPos(y);

`

The problem is that the viewer is not scrolling to the right position so what is the mistake in my reflection?

Thanks
Daniel