flutter_inappwebview
flutter_inappwebview copied to clipboard
The PDF display is not working on Android.
- [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
- This
- Than that
- Then
Images
Stacktrace/Logcat
👋 @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!
I am getting empty screen when I got pdf in url can I know why I got this error?
I have the same issue on Android. Works fine on iOS.
Suspect similar cause due to https://play.google.com/store/apps/details?id=com.google.android.webview
this also happened in another plugin https://github.com/DavBfr/dart_pdf/issues/1517#issuecomment-1789169297
@orangeyong I have faced the same issue. Do you have a solution yet?
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]';
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.