Simple PDF Viewer within a TabbedPage


Hi there,
I have a TabbedPage that has 4 ContentPage Children. One of these ContentPages is a simple PDF viewer as outlined here:https://help.syncfusion.com/xamarin/sfpdfviewer/getting-started. I have modified it slightly to accept a URL to a PDF file.
It works well - however, when I am unable to swipe left / right to go to the other ContentPages. Also, when I navigate away, the PDF automatically scrolls back to the start. Any ideas on how I can prevent this? Code below for reference

XAML - TabbedPage

            xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
            x:Class="App.Views.InterviewTabbedView"
            NavigationPage.HasBackButton="False"
            Title="{Binding PageTitle}">

   
       
       
   


XAML - ContentPage (PDF)

             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="App.Views.CvView"
             xmlns:sfpdfviewer="clr-namespace:Syncfusion.SfPdfViewer.XForms;assembly=Syncfusion.SfPdfViewer.XForms" 
             Padding="0,0,0,0"
             Title="CV">
    
   

       

           

               
                   
                   
               

               
               

           

       

   



View CS

    public partial class CvView : ContentPage
    {
        DocumentViewModel cv;

        public CvView()
        {
            InitializeComponent();

            BindingContext = cv = new DocumentViewModel();
        }

        protected override void OnAppearing()
        {
            base.OnAppearing();

 
                // this works with actual pdf. extract doc downloader from backup in android and rename the name space
                Stream documenStream = DependencyService.Get().DownloadPdfStream(cv.DocUrl, "CvFile");


                //Loads the PDF document as Stream to PDF viewer control
                pdfViewerControl.LoadDocument(documenStream);
  

        }



    }


10 Replies

SH Shaun October 25, 2017 09:27 PM UTC

Forum is being wacky and wont let me edit my initial post. the CS is good.. bu tthe PDF XAML is below

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="App.Views.CvView"
             xmlns:sfpdfviewer="clr-namespace:Syncfusion.SfPdfViewer.XForms;assembly=Syncfusion.SfPdfViewer.XForms" 
             Padding="0,0,0,0"
             Title="CV">

    

    <ContentPage.Content>


        <StackLayout VerticalOptions="Start" HorizontalOptions="Fill
                     " Orientation="Vertical">


                  <Grid IsVisible="{Binding DisplayDoc}" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">


                                 <sfpdfviewer:SfPdfViewer x:Name="pdfViewerControl" Grid.Row="1" HorizontalOptions="Fill" VerticalOptions="Fill">
                </sfpdfviewer:SfPdfViewer>


            </Grid>


        </StackLayout>



    </ContentPage.Content>

</ContentPage>


SH Shaun October 26, 2017 08:35 AM UTC

An update - I have managed to avoid the constant re-downloading by moving the code out of the OnAppearing function.

Still not sure how to be able to horizontal swipe between screens of the tabbedView. 



BS Balasubramanian Sundararajan Syncfusion Team October 26, 2017 11:58 AM UTC

Hi Shaun, 

Thank you for using Syncfusion product. 

Based on your requirement we have created a sample in which we have added a tabbed page in Xamarin.Forms and added 3 separate PDF viewer control as a children of tabbed page. We are able to switch between the tabbed pages by swiping left and swiping right on the screen in Xamarin.Forms (Android and UWP). But we could not switch between the tabbed pages in Xamarin.Forms iOS which is a behavior in iOS platform. To ensure this behavior we have created a tabbed page sample with and without PDF viewer control and the same can be downloaded from the following link, 



Please try the above sample and let us know whether you are facing issues while switching between the pages in Xamarin.Forms Android and UWP. 

Thanks, 
Balasubramanian S 
 



SH Shaun October 26, 2017 10:53 PM UTC

Thanks for this. It does indeed work when I run it. However, when I copy it into my solution, to only works if I swipe on the top 20px padding. Something in my solution is hijacking the swipe but I can't find what. 

Any tips of what I should look for (I know that is a broad question)  I'm trying to get this work for Android in the first instance/

Thanks







SH Shaun October 27, 2017 12:06 AM UTC

I stripped back a copy of my entire solution to be a carbon copy of the pages in the sample... still no good.

I did notice that I am using a newer version of XF - 2.4.0.282. The sample is using 2.3.x



BS Balasubramanian Sundararajan Syncfusion Team October 27, 2017 01:09 PM UTC

Hi Shaun, 

We could not reproduce the issue in switching between the pages by swiping left/right after updating the Xamarin.Forms version to 2.4.0.282 and the sample can be downloaded from the following link, 


Can you please provide the sample project in which you are facing the issue? So that we can analyze the issue in your sample and provide you better solution. 

Thanks, 
Balasubramanian S 



SH Shaun October 31, 2017 12:44 AM UTC

Good news - that means it's fixable! I have attached a stripped down version of my project. Problem still exists and it is basically an import of your sample so should be easy enough to work out what is stopping it from working.

I had to remove the packages to get it under the 30MB limit. Let me know if that presents a problem for you and I can work out a way to get it to you with the packages intact.


Thanks again


Shaun


Attachment: H1PaperlessApp__Copy_1f405a1.zip


BS Balasubramanian Sundararajan Syncfusion Team October 31, 2017 06:26 PM UTC

Hi Shaun, 
 
Thank you for your update. 
 
We have analyzed the sample provided by you in your previous update and We could see that the codes used in your sample project is same like the sample we have updated in our previous update. Still we could not reproduce the issue in switching between the pages by swiping left/right. We suspect that the issue occurs only in your physical device. So we request you to provide the following details which will help us to analyze and assist you better. 
 
OS (Android version): 
Device Details: 
 
Please let me know if you have any concern. 
 
Thanks 
Balasubramanian S 



SH Shaun November 5, 2017 09:42 PM UTC

I've been using the same emulator for both your sample and my app. Its using Android 7 with device of Nexus 10.


I have tried to run this on my Pixel C also running Android 7 with the same issue.



BS Balasubramanian Sundararajan Syncfusion Team November 9, 2017 05:50 AM UTC

Hi Shuan,   
  
A support incident to track the status of this query has been created under your account. Please log on to our support website to check for further updates.    


Kindly let us know if you need further assistance.     
  
Thanks,   
Balasubramanian S   


Loader.
Up arrow icon