Opening pdf file from url

-- -- 922 Reputation points
2023-09-21T04:12:32.6833333+00:00

Hi

I am using this code to open a pdf file from a url;

var DocPath = "http://mydomain.com/Docs/MyDoc.PDF";
Launcher.TryOpenAsync(new System.Uri(DocPath));

However I am getting the 'Cannot display PDF (MyDoc.PDF cannot be opened)' error.

Tried below code as well with no luck.

  Uri uri=new Uri(DocPath);

  await Browser.Default.OpenAsync(uri,BrowserLaunchMode.SystemPreferred);

What is the issue? Are there any special permission required in MAUI to open urls/pdf?

If I enter url [http://mydomain.com/Docs/MyDoc.PDF] in a desktop browser the pdf opens fine.

Thanks

Regards

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,369 questions
{count} votes

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.