flutter_inappwebview icon indicating copy to clipboard operation
flutter_inappwebview copied to clipboard

The PDF display is not working on Android.

Open SureshPetluri opened this issue 1 year ago • 10 comments

  • [x] I have read the Getting Started section
  • [x] I have already searched for the same problem

Environment

Technology Version
Flutter version
Plugin version
Android version
iOS version
macOS version
Xcode version

Device information:

Description

Expected behavior:

Current behavior:

Steps to reproduce

  1. This
  2. Than that
  3. Then

Images

Stacktrace/Logcat

SureshPetluri avatar Sep 29 '23 04:09 SureshPetluri

👋 @SureshPetluri

NOTE: This comment is auto-generated.

Are you sure you have already searched for the same problem?

Some people open new issues but they didn't search for something similar or for the same issue. Please, search for it using the GitHub issue search box or on the official inappwebview.dev website, or, also, using Google, StackOverflow, etc. before posting a new one. You may already find an answer to your problem!

If this is really a new issue, then thank you for raising it. I will investigate it and get back to you as soon as possible. Please, make sure you have given me as much context as possible! Also, if you didn't already, post a code example that can replicate this issue.

In the meantime, you can already search for some possible solutions online! Because this plugin uses native WebView, you can search online for the same issue adding android WebView [MY ERROR HERE] or ios WKWebView [MY ERROR HERE] keywords.

Following these steps can save you, me, and other people a lot of time, thanks!

github-actions[bot] avatar Sep 29 '23 04:09 github-actions[bot]

I am getting empty screen when I got pdf in url can I know why I got this error?

SureshPetluri avatar Sep 29 '23 04:09 SureshPetluri

I have the same issue on Android. Works fine on iOS.

SeltiOrg avatar Oct 20 '23 22:10 SeltiOrg

@orangeyong I have faced the same issue. Do you have a solution yet?

TrongBa avatar Dec 07 '23 05:12 TrongBa

The solution work for me,

Use Google Docs Viewer: A common workaround for this limitation in Android is to use Google Docs Viewer to display the PDF within the WebView. You can load the PDF URL through Google Docs Viewer by embedding the PDF URL into a Google Docs Viewer URL. Here's an example of how you could format the URL:

String url = 'https://docs.google.com/gview?embedded=true&url=[PDF_URL]';

TrongBa avatar Dec 07 '23 06:12 TrongBa

The solution work for me,

Use Google Docs Viewer: A common workaround for this limitation in Android is to use Google Docs Viewer to display the PDF within the WebView. You can load the PDF URL through Google Docs Viewer by embedding the PDF URL into a Google Docs Viewer URL. Here's an example of how you could format the URL:

String url = 'https://docs.google.com/gview?embedded=true&url=[PDF_URL]';

I've tried using the Google Docs Viewer but it still shows a white screen occasionally. Sometimes I have to try 5 or 6 times to reproduce it. The link I was using is this: https://docs.google.com/gview?embedded=true&url=https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf

Device: Galaxy S21 (Android 14) Chrome: 123.0.6312.118

I also noticed that the onNavigationEvent function in the ChromeSafariBrowser is getting called with "FINISHED" when the page loads properly, but gets called with “ABORTED” when it doesn't.

Colman avatar Apr 16 '24 23:04 Colman