Skip to content Skip to sidebar Skip to footer

How To Load The Online Pdf Files In Xamarin Webview?

I have trying to load and display the online pdf file (file from sharepoint link) in Xamarin forms Webview. To load the pdf, i have implemented the pdf viewer using custom renderer

Solution 1:

If the url contains the prefix https , you should add the following code in Android project . Because After Android 9 (API level 28), cleartext support is disabled by default.

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?><manifest...><uses-permissionandroid:name="android.permission.INTERNET" /><application...android:usesCleartextTraffic="true"...>
        ...
    </application></manifest>

And since you want to load remote pdf , you just need to load url directly .file:///android_asset/pdfjs/web/viewer.html is for local pdf .

Control.LoadUrl(string.Format("https://drive.google.com/viewerng/viewer?url={0}", "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"));

I used the url which provided by @SushiHangover and it works fine on my side .

Post a Comment for "How To Load The Online Pdf Files In Xamarin Webview?"