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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to open file from external storage and load to pdfreader?

Thread ID:





132597 Sep 11,2017 01:32 PM UTC Sep 12,2017 07:26 AM UTC Xamarin.Android 1
Tags: PdfViewer
Ishwor Khanal
Asked On September 11, 2017 01:32 PM UTC

I tried this way but got nothing in return

 var directoryPath = Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryDownloads);
            using (FileStream stream = new FileStream(directoryPath.AbsolutePath + "/" + "test.pdf",FileMode.Open,FileAccess.Read) )

Sathish Sivakumar [Syncfusion]
Replied On September 12, 2017 07:26 AM UTC

Hi Ishwor, 

Thank you for using Syncfusion products. 

We can read the PDF document from External Storage and display it into SfPdfViewer in Xamarin.Android. The following code snippet illustrates how to open the PDF document from external storage and read it as a Stream. 

private Stream ReadPdfStreamFromExternalStorage() 
//Get the path of external storage directory. Here we used download directory to read PDF document 
String path = Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryDownloads).AbsolutePath; 
//Read the specific PDF document from the download directory 
Java.IO.File filePath = new Java.IO.File(path+"/test.pdf"); 
// Check whether the file is exist in the download directory 
if (filePath.Exists()) 
// Convert the file path to stream to display it into SfPdfViewer 
return new FileStream(filePath.AbsolutePath, FileMode.Open, FileAccess.Read); 
// throw exception if the file is not found in the appropriate directory 
throw new FileNotFoundException("File not found"+ filePath.AbsolutePath.ToString()); 

We have also attached the sample in the below link for your reference. 

Note: Kindly ensure the PDF document that you want display in SfPdfViewer is available in the appropriate external storage directory. 

Please let us know if you need any other assistance. 



This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon