This is a migrated thread and some comments may be shown as answers.

Issue when scrolling a PDF

1 Answer 154 Views
PdfViewer
This is a migrated thread and some comments may be shown as answers.
Paul Ridden
Top achievements
Rank 1
Veteran
Paul Ridden asked on 08 Apr 2019, 02:42 PM

As there currently isn't a way to determine when a page changes when scrolling, I hook into the PropertyChanged event of the RadPdfViewer and check the VisiblePagesStartIndex property, however when scrolling to the last page of the PDF the VisiblePagesStartIndex does not match, for example, I have a 10 page PDF document and when I scroll all the way to the bottom, the last VisiblePagesStartIndex property change is 8, when it should be 9. If I then invoke the NavigateToNextPageCommand then the VisiblePagesStartIndex property changes to the expected value of 9, although I am already at the bottom of the document.

 

In effect I need to know when I reach the end of the PDF so that I can update my own UI buttons to reflect the current position in the document, for example, disabling the down button when I can no longer navigate to a next page. I can achieve this when using the NavigateToNextPageCommand and NavigateToPreviousPageCommand method of document navigation but not when scrolling.

 

I have tried a work around where if the VisiblePagesStartIndex is 8 then invoke the NavigateToNextPageCommand but this doesn't work when scrolling back up the document.

1 Answer, 1 is accepted

Sort by
0
Petar Marchev
Telerik team
answered on 10 Apr 2019, 03:42 PM
Hi Paul,

1. In order to determine when a new page enters the viewport, and when a page leaves the viewport, you can use the PropertyChanged event handler and see if either of these two properties have changed - VisiblePagesStartIndex, VisiblePagesCount. This is actually not a work-around but the intended way to find out which page enters or leaves the screen.

2. When you scroll to the bottom of the document, the start index may not match the last page index, because more than 1 page may be visible on the screen. As I explained recently in another ticket, the start index is the index of the first visible page on screen, and the count is the number of all visible pages.

In the particular case you mentioned, I suspect that the first visible page is the one with index 8, and the visible pages count is 2, so you are seeing pages with index 8 and 9. This means that you are also viewing the last page of the document, but it seems that our command is not smart enough to know that the last page is currently visible and it says that it can execute.

3. There is no way to know if you have reached the end of the document. Internally we use a scroll view but we have not yet introduced an API that would allow you to determine what portion of a page or what portion of the document is on screen. At this moment I cannot suggest a way for you to figure out the Viewport rect.

However, we may consider such a feature request. Can you explain in more details what is the final result you are after? We have built-in toolbar items, can you utilize them to achieve the desired effect? Is there any missing functionality in the toolbar that forces you to create your own UI?

Also, if we were to improve the nav-to-next-page command, to be smarter, would that work for you, or would you still need to find out whether you have reached the end of the document?

Let me know if you need any other information.

Regards,
Petar Marchev
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
PdfViewer
Asked by
Paul Ridden
Top achievements
Rank 1
Veteran
Answers by
Petar Marchev
Telerik team
Share this question
or