Anthony Wieser
Anthony Wieser

Reputation: 4611

How can I programmatically launch a PDF file from a URI in a Windows Store App on 8.1?

I've tried simply using the launcher, but that doesn't behave very well.

If I call

await Launcher.LaunchUriAsync(...)

A copy of the browser opens, but sometimes it just sits there blank, and other times puts up a message, asking if you want to open or save it. If you choose open, it starts reader, and opens another window, which happens to cover the window that launched it in the first place, leaving a blank browser window.

I'm pretty sure it would be possible to download the file myself manually, and then call LaunchFileAsync, however there are then lifetime issues with how long the file can hang around, and also that's a lot of work.

Any other ideas?

Upvotes: 0

Views: 963

Answers (1)

Jon
Jon

Reputation: 2891

Set the content type like this and it should load fine:

Windows.System.LauncherOptions options = new Windows.System.LauncherOptions();
options.ContentType = "application/pdf";
Windows.System.Launcher.LaunchUriAsync(new Uri(fileUrl), options);

Upvotes: 3

Related Questions