0

I see that the common implementation of this is to simply append the string to a Google URL, however this will only work with PDF's hosted on the internet. My PDF is a local one and I want to embed it in an IFrame and put it into my webview. I also read somewhere that enabling hardware acceleration can help, which I currently do have enabled. However, the following is what is happening.

string html = "<html><iframe src=\"/storage/emulated/0/Attachment/test.pdf\" width=\"100%\" height=\"100%\"></iframe></html>";

webView.LoadData(html, "text/html", "base64");

That is essentially what I am trying to do. However when I load the WebView in my app, I see WEBPAGE NOT AVAILABLE ... could not be loaded because net::ERR_INVALID_URL

To add onto this, the reason I am doing it this way is because the PDF renderer class for Android is only available for API's 21 and higher. I need my app to support at minimum AP 15.

Patrick Zawadzki
  • 456
  • 2
  • 6
  • 26
  • After using `Uri path = new Uri(f.AbsolutePath); string html = ""; ` I am still unable to load the file... the returned URI is `"file:///storage/emulated/0/Attachments/test.pdf"` **Edit**: To mention, I also have the webview's AllowFileAccess and AllowContentAccess and AllFileAccessFromFileURLs all set to `true` – Patrick Zawadzki Jul 15 '15 at 19:00
  • 1
    The thing you are trying to do will not work. The trick with viewing PDF via Google Drive works because Google Drive can access these PDFs. The job of WebView is only to show you Google Drive's page. It will not magically upload your local document to Google Drive. If you want to show local PDF files, either just launch a viewing intent hoping that the user have a PDF viewer app installed, or bundle your app with a PDF rendering library. – Mikhail Naganov Jul 15 '15 at 23:36

0 Answers0