guiwhatsthat
guiwhatsthat

Reputation: 2434

Xamarin.Forms Open local PDF

I tried to open a locally stored pdf with xamarin.

example code:

var files = Directory.GetFiles(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData));
var filepath = "file://" + files[0];
if (File.Exists(filepath))
{
     await Launcher.OpenAsync(filepath);
}

But the file does not open. The only message I get is (android device): enter image description here

what do I miss?

EDIT

the variable filepath contains: file:///data/user/0/com.companyname.scgapp_pdfhandler/files/.config/test.pdf

also tried

file://data/user/0/com.companyname.scgapp_pdfhandler/files/.config/test.pdf

does not help

Upvotes: 0

Views: 1210

Answers (1)

SomeStudent
SomeStudent

Reputation: 3048

Figured I would add my comment as an answer for easier visibility in case others run into it in the future.

Pass a OpenFileRequest object instead, if you use a string it has to be the correct uri scheme for it. I suspect the uri scheme you are passing to it isn't something that is understood by the system

Upvotes: 1

Related Questions