VS 2017 Xamarin, open PDF file and configurating copies number

alfonso leon 1 Reputation point
2020-09-07T09:11:15.557+00:00

VS 2017 Xamarin, open PDF file and configurating copies number

I'm developing app with xamarin an c# and I'd like to open a pdf file and to can configurate de copies number for example copies = 2.
Thanks

my code---------------------------------------------------------

public void OpenFile(string filePath, string filename)
{
var bytes = File.ReadAllBytes(filePath);

        //Copy the private file's data to the EXTERNAL PUBLIC location
        string externalStorageState = global::Android.OS.Environment.ExternalStorageState;
        string application = "application/pdf";

        string extension = System.IO.Path.GetExtension(filePath);

        var externalPath = global::Android.OS.Environment.ExternalStorageDirectory.Path + "/" + filename + extension;
        File.WriteAllBytes(externalPath, bytes);

        Java.IO.File file = new Java.IO.File(externalPath);
        file.SetReadable(true);
        Android.Net.Uri uri = Android.Net.Uri.FromFile(file);
        Intent intent = new Intent(Intent.ActionView);
        intent.SetDataAndType(uri, application);
        intent.SetFlags(ActivityFlags.ClearWhenTaskReset | ActivityFlags.NewTask);            

        intent.SetFlags(ActivityFlags.NoHistory);
        intent.AddFlags(ActivityFlags.ClearTask);
        try
        {
            this.StartActivity(intent);
            Finish();
        }
        catch (Exception)
        {
            Toast.MakeText(this, "No hay aplicaciones instaladas para abrir PDF's", ToastLength.Short).Show();
        }
    }
Not Monitored
Not Monitored
Tag not monitored by Microsoft.
39,794 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Leon Laude 85,816 Reputation points
    2020-09-07T11:12:15.897+00:00

    Hi,

    Xamarin is currently not supported in the Q&A forums, the supported products are listed over here https://video2.skills-academy.com/en-us/answers/products (more to be added later on).

    You can ask the experts in the dedicated Xamarin forum over here:
    https://forums.xamarin.com/

    ----------

    (If the reply was helpful please don't forget to upvote or accept as answer, thank you)

    Best regards,
    Leon

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.