Open Pdf File in Xamarin.forms

前端 未结 3 446
夕颜
夕颜 2020-12-10 14:16

Currently I\'m writing a Privacy policy for apps that I put in PDF format.
May I ask about how to open PDF file for Xamarin.Forms? Any references Source Code?

3条回答
  •  天命终不由人
    2020-12-10 14:50

    • Hosted

    Hosted PDF Files are not opening in Webview. as iOS Webview can open PDF, While android Webview can not open the PDF Files. so if PDF url is Public, Then you can use below code for Android without use any library as well as you did not required to platform specific code.

        var pdfUrl = "http://yourdomain.com/pdffile.pdf";
        var googleUrl = "http://drive.google.com/viewerng/viewer?embedded=true&url=";
        if(Device.RuntimePlatform == Device.iOS)
        {
            webView.Source = pdfUrl;
        }
        else if(Device.RuntimePlatform == Device.Android)
        {
            webView.Source = new UrlWebViewSource() { Url = googleUrl + pdfUrl };
        }
    

提交回复
热议问题