Render PDF from internal storage in UWP

I need to open a pdf file stored in the internal storage of windows phone.

First of all, I download the pdfs files with HttpClient client and store it in the LocalFolder:

        client.GetAsync(linkPDF).ContinueWith((requestTask) =>
        {
            HttpResponseMessage response = requestTask.Result;

            response.EnsureSuccessStatusCode();

            var bytes = response.Content.ReadAsByteArrayAsync().Result;
            var path = ApplicationData.Current.LocalFolder.Path;
            string localPathCatalogo = Path.Combine(path, filename);
            Debug.WriteLine(localPath);
            File.WriteAllBytes(localPath, bytes);

        });

and then throughout a xamarin webview (https://developer.xamarin.com/recipes/cross-platform/xamarin-forms/controls/display-pdf/) I want to render it.

If I store the pdf in Assets folder I can render it with no problem:
Control.Source = new Uri(string.Format("ms-appx-web:///Assets/pdfjs/web/viewer.html?file={0}", new Uri("ms-appx-web:///Assets/file.pdf")));

but don't in local:
Control.Source = new Uri(string.Format("ms-appx-web:///Assets/pdfjs/web/viewer.html?file={0}", new Uri("ms-appx-web:///local/anotherfile.pdf")));

has someone any idea about why I can't render it?

I've try put different paths but without success.

Thanks in advance!

Answers

  • SivaShankarArumugamSivaShankarArumugam USMember ✭✭✭

    @RobertoMartinGuillen I too have the same issue. did you find any workarounds.

  • Hi Siva, no, I still looking for a solution

  • omarantonio16omarantonio16 Member ✭✭

    Only PDFs in the assets folder or in the package work. And here is another implication, if you can show pdfs created at run time only in Debug and Release mode, but if you try to upload the application to the Store, the above is impossible since you do not have access to the Assets folder, it's incredible that after so long there is still no solution for this.

Sign In or Register to comment.