pdf file open with in xamarin ios

AMNishanthiKumariAMNishanthiKumari USMember ✭✭
edited December 2018 in Xamarin.iOS

This is my code to open pdf file in xamarin ios.

UIDocumentPickerViewController documentPicker = new UIDocumentPickerViewController(NSUrl.FromFilename(filepath), UIDocumentPickerMode.ExportToService);
documentPicker.DidPickDocumentAtUrls += (object sender, UIDocumentPickedAtUrlsEventArgs e) =>
{
var PreviewController = UIDocumentInteractionController.FromUrl(NSUrl.FromFilename(filepath));
PreviewController.Delegate = new UIDocumentInteractionControllerDelegateClass(UIApplication.SharedApplication.KeyWindow.RootViewController);
Device.BeginInvokeOnMainThread(() =>
{
PreviewController.PresentPreview(true);
});

};

I need to use open with dialog box to select adobe pdf reader. Is it possible to do? In code after open pdf file its not possible to edit. I need to trigger “file open with” dialog so end-user needs to select app.

Tagged:

Best Answer

Answers

  • AMNishanthiKumariAMNishanthiKumari USMember ✭✭
    edited December 2018

    Thanks @Quintán
    I had found a another one. directly open acrobat reader.

        var url = new NSUrl($"com.adobe.adobe-reader://");
         UIApplication.SharedApplication.OpenUrl(url);
    

    Now i need to give file path to this. I tried but getting errors.

    var url = new NSUrl($"com.adobe.adobe-reader:{filepath}");
    UIApplication.SharedApplication.OpenUrl(url);
    
Sign In or Register to comment.