Forum Xamarin.Forms

Pdf viewer issue

Hello Everyone
i have a small problem
i am using pdf viewer from this link " https://developer.xamarin.com/recipes/cross-platform/xamarin-forms/controls/display-pdf/ "
it is working fine for latest android versions
but when i use mobile with android version 16 it shows up an error
i searched and found this hint

but i don't understand what should i do with it
any help please
Thanks

Answers

  • seanydaseanyda GBMember ✭✭✭✭✭

    In the file location specified it has this line of code -
    var DEFAULT_URL = 'compressed.tracemonkey-pldi-09.pdf';

    It's telling you to reference the file location of the local PDF you want to display via that DEFAULT URL variable.

  • abdoelzamalkawyabdoelzamalkawy EGMember ✭✭✭
    edited September 2017

    how should i change it from my code ??
    this is my renderer

    [assembly: ExportRenderer (typeof(CustomWebView), typeof(CustomWebViewRenderer))]
    namespace DisplayPDF.Droid
    {
        public class CustomWebViewRenderer : WebViewRenderer
        {
            protected override void OnElementChanged (ElementChangedEventArgs<WebView> e)
            {
                base.OnElementChanged (e)
                if (e.NewElement != null) {
                var customWebView = Element as CustomWebView;
                Control.Settings.AllowUniversalAccessFromFileURLs = true;
                Control.LoadUrl (string.Format ("file:///android_asset/pdfjs/web/viewer.html?file={0}", string.Format ("file:///{0}", WebUtility.UrlEncode (customWebView.Uri))));
            }
            }
        }
    }
    
Sign In or Register to comment.