How to open PDF file in Xamarin.Forms

Can anyone help me to open PDF file in Xamarin.Forms . I'm developing a mobile app using Xamarin.Forms.

Best Answer


  • Hello MitchMilam,

    Thanks for considering my query.

    I've tried these link but there is no luck-


    There are some methods which are not supported in android project.

    Kindly provide me a zip file of working sample if possible.

    Thanks in advance.

  • Here is the error I'm getting when using

    Java.Lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at --- End of managed exception stack trace ---
    at java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at at
    at Caused by: java.lang.reflect.InvocationTargetException
    at at java.lang.reflect.Method.invoke(Native Method)
    at at java.lang.reflect.Method.invoke(
    at at$
    at ... 1 more
    at Caused by: md52ce486a14f4bcd95899665e9d932190b.JavaProxyThrowable: System.NullReferenceException: Object reference not set to an instance of an object
    at at Xamarin.Forms.Platform.Android.FormsApplicationActivity.OnPrepareOptionsMenu (Android.Views.IMenu)
    at Android.App.Activity.n_OnPrepareOptionsMenu_Landroid_view_Menu_ (intptr,intptr,intptr) [0x00011] in /Users/builder/data/lanes/1780/3518c4ce/source/monodroid/src/Mono.Android/platforms/android-21/src/generated/Android.App.Activity.cs:4151
    at at (wrapper dynamic-method) object.55bd698f-a13d-4d0d-bdb5-898eede2ba52 (intptr,intptr,intptr)
    at at md5530bd51e982e6e7b340b73e88efe666e.FormsApplicationActivity.n_onPrepareOptionsMenu(Native Method)
    at at md5530bd51e982e6e7b340b73e88efe666e.FormsApplicationActivity.onPrepareOptionsMenu(
    at at
    at at
    at at
    at at$
    at at android.os.Handler.handleCallback(
    at at android.os.Handler.dispatchMessage(
    at at android.os.Looper.loop(
    at at
    at ... 4 more

  • KaaminichaudharyKaaminichaudhary USMember
    edited June 2015

    I've completed this in Xamarin.Android, here is code

    using Uri = Android.Net.Uri;
    string downloadsPath = Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryDownloads).AbsolutePath;
    string filePath = "sample.pdf";
    string fullPath = Path.Combine(downloadsPath,filePath);
    Java.IO.File file= new Java.IO.File(fullPath);
    Uri path=Uri.FromFile(file);
    Intent i =new Intent(Intent.ActionView);

    But my question is, can we write native code in PCL so that we don't need to write code which is platform specific.

    Any Help

Sign In or Register to comment.