Display pdf from url link instead of local storage from app folder

DarshanJSDarshanJS USMember ✭✭✭

@AlessandroCaliaro, @NMackay,@FredyWenger,@AdamP,@MihaMarkic

Hi Guys,
sorry for the trouble,

i referred this link https://developer.xamarin.com/recipes/cross-platform/xamarin-forms/controls/display-pdf/ to view pdf
i am able to display pdf from resource file without an issue
but i want to view pdf by providing link, for example http://www.axmag.com/download/pdfurl-guide.pdf instead of giving path of assets folder

here is my code

            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:///android_asset/Content/{0}", WebUtility.UrlEncode(customWebView.Uri))));
                        }

which works fine.

i tried replacing last line of code to below code but it gives unexpected error,

Control.LoadUrl(string.Format("file:///android_asset/pdfjs/web/viewer.html?file={0}", string.Format("http://www.axmag.com/download/pdfurl-guide.pdf", WebUtility.UrlEncode(customWebView.Uri))));

i don't want to view in browser i want to display it within app itself

Please help me guys

Thanks in advance

Best Answer

Answers

  • DarshanJSDarshanJS USMember ✭✭✭

    @AlessandroCaliaro, @NMackay
    Please help its my last part of my app, so my app will be completed

  • DarshanJSDarshanJS USMember ✭✭✭

    @MihaMarkic said:
    You would have to download the file yourself to a public directory and start an activity that opens it. You can use DownloadManager for that.

    Whether it will open in same app or browser, if it is in app can you please provide me any reference link

  • MihaMarkicMihaMarkic SI ✭✭✭✭

    It will open in a registered PDF viewer (or you can pick one if there are many).

  • DarshanJSDarshanJS USMember ✭✭✭
    edited October 11

    @MihaMarkic said:
    You would have to download the file yourself to a public directory and start an activity that opens it. You can use DownloadManager for that.

    Hi can you please provide any link or code to refer how to download it and view i am not getting it which should work for both iOS and Android i want to download it pragmatically not without using any package.

Sign In or Register to comment.