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

SfPdfViewer crashes on Android

Hi, 

I'm using Xamarin.Forms for my Application.
In particular, this app downloades pdf in background and stores it in Device Storage.

This is my code: 

  switch (Device.RuntimePlatform)
               {        
                    case Device.Android:
                        MemoryStream = new MemoryStream(File.ReadAllBytes(filePath));
                        this.pdfViewerControl.InputFileStream = MemoryStream;
                        break;
                    case Device.UWP:
                        if (LoadedFileStream != null) LoadedFileStream.Close();
                        LoadedFileStream = new FileStream(filePath, FileMode.Open);
                        this.pdfViewerControl.LoadDocument(LoadedFileStream);
                        break;
                }

It works for UWP, but crashes for Android.

Where am I doing wrong? 

Thanks for your work



3 Replies

GR Gayathri Ramalingam Syncfusion Team September 16, 2019 11:58 AM UTC

Hi Mauro,  
  
We tried to reproduce the issue “Application crashes while loading PDF document from local storage using PDF Viewer” in Xamarin.Forms.Android, but it is working fine as expected. Kindly refer the sample in the below link which we created to reproduce the reported issue.  
 
 
Note: 
The PDF files and the file paths used in the code snippet as well as in the sample are only meant to be examples. Before running the sample or using the code in your own application, please ensure that the PDF files exist in the specified paths. The file name and path can also be changed to suit your needs. 
 
Kindly share the following details to analyze more on this issue and it will be helpful for us to provide solution at the earliest. 
 
 
1.       Modify / Simple sample with which the issue could be reproduced.  
2.       Replication procedure to reproduce the issue or screen shot illustrating the issue.  
3.       Android device specification with the OS version.  
4.     PDF document with which the issue could be reproduced. (Can you please confirm us whether you are using same PDF document for UWP platform?) 
5.       Exception/Stack trace of the issue. 
6.       Xamarin.Forms version. 
7.       SfPdfViewer version. 
8.       Third party assembly details if you used any. 
 
  
 
With Regards, 
Gayathri R 



MA Mauro September 17, 2019 10:23 AM UTC

I use a Huawei MediaPad M5. Android 9 , but happens with every device, emulated or none.

The app crashes with every pdf. In my application I download also zip file with html and css that I could open from a webview. The same pdf works fine with uwp.

The file is stored in "/storage/emulated/0/Android/data/com.companyname.MyApp/files/Documents/1553523980947FILE_FILE_3256.pdf" that exists correctly. (Other types of file are downloaded in the same directory and I correctly use them in my app)
Xamarin Forms Version:   v4.0.30319 
SfpdfViewer Version : 17.2451.0.28 

You can find a log file attached.

Thanks for your work


Attachment: log_58e382b6.rar


GR Gayathri Ramalingam Syncfusion Team September 18, 2019 02:03 PM UTC

Hi Mauro, 
 
We have tried to reproduce the issue “Application crashes while loading PDF document from local storage using PDF Viewer” in Xamarin.Forms.Android, but it is working fine as expected. Kindly refer the sample in the below link which we created to reproduce the reported issue.   
Could you please try the above sample and let us know whether it meets your requirement or not?  If you still face the issue, we suspect that this issue might occur with the specific PDF document. In this case, could you please share the PDF document or else modify the sample with which the issue could be reproduced? It will be easy for us to investigate further and assist you with the better solution.    
 
With Regards, 
Gayathri R 



Loader.
Live Chat Icon For mobile
Up arrow icon