Download Pdf and show in Pdfviewer

Hello ,

I download a file and email it with a button .

But i want to download the file and show it in a Pdfviewer.

How do i make this work ?

 async void Button_Clicked(object sender, EventArgs e)
        {
            HttpClient client = new HttpClient();
         
            var response = await client.GetAsync("http://africau.edu/images/default/sample.pdf");
            var bytes = await response.Content.ReadAsByteArrayAsync();

            var file = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "sample.pdf");
            File.WriteAllBytes(file, bytes);

            var message = new EmailMessage
            {
                Subject = "Hello",
                Body = "World",
            };
            message.Attachments.Add(new EmailAttachment(file));

            await Email.ComposeAsync(message);
        }

2 Replies 1 reply marked as answer

SP Satheesh Palanisamy Syncfusion Team August 24, 2020 12:04 PM UTC

Hi Boris, 

We have prepared the sample to download and load the PDF document in to the SfPdfViewer in the link below.

 

Kindly try the above sample and let us know whether the above solution resolved the query.

 

Regards,  
Satheesh Palanisamy. 


Marked as answer

BO Boris Oprit August 26, 2020 05:17 PM UTC

Thanks ,

Works great.

Loader.
Up arrow icon