Error opening pdf with app

GaganSinghGaganSingh USUniversity ✭✭✭

Hi, My pdf wont open and every pdf app i try to open it with gives an error message that says "Cannot display PDF (BCP_Emergency.pdf cannot be opened)"
My pdf is in the root directory (same location as the assets and resources folders).
Also, please dont suggest a third party api or opening it with a webview. i need to use a pdf app to open this pdf.
By the way, this is being called via DependencyService from my xamarin.forms project

` public void OpenPdf(string fileName)
Android.Net.Uri uri = Android.Net.Uri.Parse("file:///"+fileName);
Intent intent = new Intent(Intent.ActionView);
intent.SetDataAndType(uri, "application/pdf");
intent.SetFlags(ActivityFlags.ClearWhenTaskReset | ActivityFlags.NewTask);

        catch (Exception)
            Toast.MakeText(Xamarin.Forms.Forms.Context, "No Application Available to View PDF", ToastLength.Short).Show();

thank you!

Sign In or Register to comment.