question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Displaying a PDF within the Webview

See original GitHub issue

Bug description: I have a WebView Container for my Webpage. Within my webpage, I link specific PDFs, just as a direct link via <a href="...pdf">My Link</a>

How can I force the WebView to display the PDF upon clicking it? Right now, the link is opened in my default browser and from there being downloaded as file. As the Webview is, e.g. on Android, based on Chromium, I’d expect Chromium just to show the PDF within the Webview / APP natively.

To Reproduce: Nothing special required, just a pure Webview and a HTML Page with a linked PDF.

Expected behavior: As the Webview is, e.g. on Android, based on Chromium, I’d expect Chromium just to show the PDF within the Webview / APP natively.

Environment:

  • OS: Android 11 “react”: “17.0.1”, “react-native”: “0.64.3”, “react-native-safe-area-context”: “3.3.2”, “react-native-web”: “0.17.1”, “react-native-webview”: “11.15.0”

Thank you so much!

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
TheAlmightyBobcommented, Mar 7, 2022

@bjspi I’m not personally aware of any such library (that doesn’t mean none exist though, just that I can’t help you), we just let third-party apps handle it for us, as there are many of those (when I try to open a PDF on my personal phone I get a list of ~8 different apps to choose from!)

1reaction
TheAlmightyBobcommented, Mar 2, 2022

@bjspi PDF viewing is not a feature of the Android Webview or even of the Chrome browser on Android.

Read more comments on GitHub >

github_iconTop Results From Across the Web

android - How can I display a pdf document into a Webview?
You can use Google PDF Viewer to read your pdf online: WebView webview = (WebView) findViewById(R.id.webview); webview.getSettings().
Read more >
Various ways to load PDF in Android webview - django-cas-ng
Various ways to load PDF in Android webview · Open Intent with startActivity · Use google docs service to load pdf in html...
Read more >
How to show pdf in android webview? - Tutorialspoint
This example demonstrate about How to show pdf in android webview. Step 1 − Create a new project in Android Studio, go to...
Read more >
Load PDF in Android WebView - Codes Easy
We can load PDF in android easily using WebView. We will be using the simplest way for displaying PDF file in android.
Read more >
How to open a PDF file in Android programmatically? - MindOrks
If you want to display PDF in your Android application, ... and the easiest way of displaying the PDF file is to display...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found