We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Zoom not working

Hello,

I'm trying to implement the PDF viewer on the Xamarin platform. But for some reason it will not pinch zoom the PDF once it is loaded. I have a test project where it does actually zoom correctly, but for this project it won't. The only difference is that in my current project gets it's files from an api instead of the files being embedded into the application itself. Could this cause the viewer not to zoom properly?

Here is my code:

Xaml:
 <ContentPage.Content>
        <StackLayout>
            <syncfusion:SfPdfViewer  x:Name="pdfViewerControl" InputFileStream="{Binding PdfDocumentStream}" Toolbar = "{StaticResource ToolbarSettings}"/>
        </StackLayout>
    </ContentPage.Content>

Xaml.cs(code behind):

 public PdfViewerPage(Sheet _sheet)
        {
            InitializeComponent();
            BindingContext = new PdfViewerViewModel(Navigation, _sheet);
            loginService = new LoginService(Navigation);
            PdfViewerResourceManager.Manager = new ResourceManager("GettingStarted.Resources.Syncfusion.SfPdfViewer.XForms", GetType().GetTypeInfo().Assembly);
        }


ViewModel:
 public Stream PdfDocumentStream
        {
            get { return pdfDocumentStream; }
            set
            {
                //Check the value whether it is the same as the currently loaded stream
                if (value != pdfDocumentStream)
                {
                    pdfDocumentStream = value;
                    OnPropertyChanged();
                }
            }
        }

async void RefreshPdf()
        {
            try
            {
                var bytes = Convert.FromBase64String(await pdfViewerService.GetPdf(sheet.Id));
                PdfDocumentStream = new MemoryStream(bytes);
            }
            catch(Exception e)
            {

            }
        }


As you can see the Api returns the file as a base64string. I'm converting it back into a stream so it can be loaded in the viewer. It gets displayed correctly so i don't suspect the file is being corrupt or anything(other files load fine too but no zoom).

If anyone has a solution that would be great!

Using version: 17.1.0.53


3 Replies

JP Jhansi Priya Ramesh Syncfusion Team July 5, 2019 05:09 AM UTC

Hi Joshua, 
 
Greetings from Syncfusion. 
When PDFViewer is placed inside the Stacklayout, We need to set the VerticalOptions and HorizontalOptions property of the PDF Viewer control to “FillAndExpand”.  
Please find the code snippet below, 
<ContentPage.Content> 
        <StackLayout> 
            <syncfusion:SfPdfViewer  x:Name="pdfViewerControl" InputFileStream="{Binding PdfDocumentStream}" Toolbar = "{StaticResource ToolbarSettings}" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand"/> 
        </StackLayout> 
    </ContentPage.Content> 
 
 
However, once the document is loaded zoom will work only after scrolling which is a defect from our side. We are currently working on this issue and the fix for this will be included in our Essential Studio Volume 2 Main Release which will be available by Mid of July 2019. 
 
Regards, 
Jhansi 
 
 



MI Mik replied to Jhansi Priya Ramesh May 8, 2020 10:17 AM UTC

Hi Joshua, 
 
Greetings from Syncfusion. 
When PDFViewer is placed inside the Stacklayout, We need to set the VerticalOptions and HorizontalOptions property of the PDF Viewer control to “FillAndExpand”.  
Please find the code snippet below, 
<ContentPage.Content> 
        <StackLayout> 
            <syncfusion:SfPdfViewer  x:Name="pdfViewerControl" InputFileStream="{Binding PdfDocumentStream}" Toolbar = "{StaticResource ToolbarSettings}" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand"/> 
        </StackLayout> 
    </ContentPage.Content> 
 
 
However, once the document is loaded zoom will work only after scrolling which is a defect from our side. We are currently working on this issue and the fix for this will be included in our Essential Studio Volume 2 Main Release which will be available by Mid of July 2019. 
 
Regards, 
Jhansi 
 
 


Having same issue on iOS with Syncfusion 17.0.4.39
the Zoom in Android works instead iOS 


AV Ashokkumar Viswanathan Syncfusion Team May 11, 2020 11:38 AM UTC

Hi Joshua, 
 
We were unable to reproduce the issue, “Zoom operation will work only after scrolling the PDF pages in iOS platform” in the product version v17.4.0.39. We have created a simple sample to replicate the issue in our side. 
 
Please find the sample in the below link, 
 
Kindly share the following details to analyze more on this issue and assist you with the better solution   
  • Simple sample/ modify the above sample to reproduce the issue. 
  • PDF document with which you have reproduced. 
  • Xamarin.Forms version.
  • Device specification.
  • Replication procedure to reproduce the issue. 
 
Regard, 
Ashok Kumar Viswanathan. 


Loader.
Live Chat Icon For mobile
Up arrow icon