Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open a pdf file inside a webview.

Tags:

android

pdf

I have an app where I've button on a webpage that is rendered inside a webview.

Now on click of button , a pdf file gets downloaded , and the same would then need to be opened inside the same webview.

like image 581
eatSleepDrinkJava.repeat Avatar asked Feb 09 '11 16:02

eatSleepDrinkJava.repeat


People also ask

How do I open a PDF in WebView?

Opening a PDF file in Android using WebView All you need to do is just put WebView in your layout and load the desired URL by using the webView. loadUrl() function. Now, run the application on your mobile phone and the PDF will be displayed on the screen.

Can we open PDF in WebView in Android?

We can load PDF in android easily using WebView. We will be using the simplest way for displaying PDF file in android. Using the Google Docs PDF viewer we could do this easily. Now lets get in to the implementation and source code.

Why PDF is not opening in WebView Android?

Unfortunately, Android does not support viewing PDFs out of the box in a WebView. Luckily, Google has a nifty little tool that allows you to perform this very task quite easily using Google Docs. Basically we will embed our PDF in a Google Doc page on-the-fly and load that.

How do I open PDF in WebView flutter?

If possible, you can display PDF documents and visit online websites using the add-in: import 'dart:html' as html; html. window. open('http:///www.website.com/document.pdf');


1 Answers

attach a download listener to the web view and change the url as follows..

"http://docs.google.com/gview?embedded=true&url=http://www.abc.com/xxxxxyyyyyxz.pdf"

it's a link used to open pdf without downloading it...

I hope it solves your problem..

like image 182
Alok Gupta Avatar answered Oct 10 '22 03:10

Alok Gupta