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

Get PdfViewer current page

2 Answers 245 Views
PdfViewer
This is a migrated thread and some comments may be shown as answers.
Joaquin
Top achievements
Rank 2
Joaquin asked on 30 Dec 2019, 12:29 PM

Hello. I'm trying to implement a control for displaying Terms and Conditions on my app using PDFViewer. I want to have an "accept" button below the viewer that Will become enabled when the user has scrolled to the bottom of the PDF (and hopefully read the document).

For this I would like to know the page number the user is currently Reading, and perhaps also an event that fires when it changes. Is this available in the PDFViewer control? I found references to VerticalScrollState, but that seems to only be available for Windows (is that right?)

What would be the correct approach to get this behavior on Xamarin Forms? Thank you

 

2 Answers, 1 is accepted

Sort by
0
Accepted
Yana
Telerik team
answered on 02 Jan 2020, 08:59 AM

Hi Joaquin,

Happy New Year!

First, regarding the current page number - 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 of RadPdfViewer and see if either of these two properties have changed - VisiblePagesStartIndex, VisiblePagesCount.  VisiblePageStartIndex specifies the index of the first visible page on screen, and the count is the number of all visible pages (there may be more than one page displayed depending on the zoom level). Here is a quick example:

this.pdfViewer.PropertyChanged += PdfViewer_PropertyChanged;

private void PdfViewer_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
    if(e.PropertyName == nameof(pdfViewer.VisiblePagesStartIndex))
    {
        var currentFirstPage = this.pdfViewer.VisiblePagesStartIndex;
    }
}

Next, regarding the "accept" button - I am afraid that currently RadPdfViewer for Xamarin does not provide support for interactive forms, we have a feature request in our public feedback portal regarding it, you can cast your vote and track its status at the link below:

PdfViewer: Interactive Forms on Xamarin

In the meantime, as a workaround, you can use try the link annotation feature of RadPdfViewer instead of a button - it includes a LinkAnnotationTapped event, which you can use to "accept" the terms.  In this way, however, the link couldn't be disabled and will be active inside the pdf document. For more details on the link annotations functionality, go to our documentation here: RadPdfViewer for Xamarin: Link Annotations.

Let me know if any additional questions pop up.

Regards,
Yana
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
0
Joaquin
Top achievements
Rank 2
answered on 03 Jan 2020, 12:51 PM
Thanks. Works like a charm!
Tags
PdfViewer
Asked by
Joaquin
Top achievements
Rank 2
Answers by
Yana
Telerik team
Joaquin
Top achievements
Rank 2
Share this question
or