1
votes

I have to display a pdf from URL. When i directly open the url in a webview then it asks me to download the pdf and then view based on the app that i want to use to view it. But I do not want to download the pdf, it must be just displayed directly.

Some answers that I went through on SO recommended to make use of docs.google.com

like here: How to display a PDF via Android web browser without "downloading" first

But this doesnt seem to be working anymore.

2
'Doesnt seem to work' is not a very accurate description of your problem.fweigl
I think you are getting something wrong. To display the content of a .pdf, it always has to be downloaded first. What you want to achieve is to only temporarily download it, and delete it again after the user exited the .pdf viewer.PKlumpp
It just displays that preview not available. Even the older examples that I went through, at the time when google had introduced this, even those examples are now showing that preview not available.frgr
@ZerO What i want is that the pdf must not be downloaded on the device. Earlier there have been solutions using google docs url, similar to the answer that I have shared in my question, but now that is not working.frgr
The pdf is always loaded into a cache, and therefore downloaded.PKlumpp

2 Answers

0
votes

use this inside your body tags

    <iframe src="http://example.com/yourpdf" width="100%" height="100%" style="border: none;">This browser does not support PDFs. Please download the PDF to view it: <a href="http://example.com/yourpdf">Download PDF</a></iframe>