Trying delay the page swiping

Hi,


I'm trying to make a PDF viewing, so the user has to "stay" on the page for x seconds, no controls visible from the SfPdfViewer, only zoom, if they need it.

This will be on Android, so the user can swipe, to change page.

Current code:

<syncfusion:SfPdfViewer x:Name="PdfViewer"
                        Grid.RowSpan="4"
                        Grid.ColumnSpan="6"
                        DocumentSource="{Binding PdfContent}"
                        PageLayoutMode="Single"
                        ShowToolbars="False"
                        ZoomMode="FitToWidth"
                        EnablePageNavigationDialog="False"
                        PageCount="{Binding TotalPageCount, Mode=OneWayToSource}"
                        PageNumber="{Binding CurrentPageNumber, Mode=OneWayToSource}"
                        EnableTextSelection="False"
                        PropertyChanged="PdfViewer_PropertyChanged"
                        EnableDocumentLinkNavigation="False">
    <syncfusion:SfPdfViewer.Background>
        <LinearGradientBrush StartPoint="0,1" EndPoint="0,0">
            <GradientStop Color="LightSteelBlue" Offset="0.0" />
            <GradientStop Color="White" Offset="1.0" />
        </LinearGradientBrush>
    </syncfusion:SfPdfViewer.Background>
</syncfusion:SfPdfViewer>



Any advice would be helpful.

Regards,

Attila


3 Replies

MM Manikandan Manickavasagam Syncfusion Team September 17, 2024 03:44 AM UTC

Hi Attila,

Based on the information and the title of this forum post, we understand that you are experiencing a delay in the SinglePageLayout mode of the PDF Viewer. We have prepared a sample using your provided code, and we are not facing any delay with the swiping operation to change pages. We have attached the sample which is used in our end please review the sample, Could you please try the provided sample and let us know whether we have missed out on anything while replicating the issue?

If we have misunderstood your query, please clarify your requirement in detail. If you are facing any issues, kindly provide the exact reproduction steps or modify the provided sample. This will help us investigate the issue further.



Regards,

Manikandan M


Attachment: DelayCheck_8ff7a098.zip


AT Attila September 17, 2024 03:51 PM UTC

Hi Manikandan M,


To clarify me requirement's, I want to delay the page switching, so the user can't go to the next page, only after X amount of seconds have passed.

So let's say he/she is on page 1, he can't go/swipe for 10 seconds, as it takes around 10 seconds to read the page.

After 10 seconds swipes to page 2, he/she can go back, but can't go to page 3, until it's "not reeded". 


Hope this adds more clarity.


Regards,

Attila



MM Manikandan Manickavasagam Syncfusion Team September 19, 2024 04:09 AM UTC

Hi Attila,


Thank you for explaining your requirements in detail. Currently, it is not possible to implement this functionality directly in the MAUI PDF Viewer. However, we have a workaround that might help. You can pause the main thread for a set number of seconds, which would delay the user's ability to swipe to the next page. However, please note that this approach has some limitations: during the delay, you won't be able to perform any operations like zooming or navigating back to the previous page.


Here is a code snippet demonstrating how this can be done:


 

private void PdfViewer_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)

{

    if (e.PropertyName == nameof(pdfViewer.PageNumber))

    {

        if (pdfViewer.PageNumber != 1 && (pdfViewer.PageLayoutMode == Syncfusion.Maui.PdfViewer.PageLayoutMode.Single))

            Thread.Sleep(10000);  // Delays page switching for 10 seconds

    }

}

 


Make sure to wire up the PropertyChanged event of the PDF Viewer and handle the above code within the wired event. This code delays the page transition for 10 seconds when switching pages. It won't affect the first page but will apply to subsequent pages.

Please try this workaround and let us know if it meets your needs.

Regards,

Manikandan M


Loader.
Up arrow icon