Open a pdf file inside a webview.

前端 未结 4 1584
眼角桃花
眼角桃花 2020-11-28 14:16

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 t

相关标签:
4条回答
  • 2020-11-28 14:26

    I don't think any browser other than Chrome supports rendering PDFs without a plugin or third party tool. It's probably easier to let the user use his own app to open PDFs.

    I used the IText PDF library mentioned in this thread Android : Is there any free PDF library for Android for a sample project. You could try getting using this API to get the PDF page as an image. I am not familiar with every aspect of Itext so it might have better way to do this.

    0 讨论(0)
  • 2020-11-28 14:30

    I do not think that the present android chrome based browser can support pdf. There are discussion about the same in android forums ( ex: link1 link2)

    Your best bet to show pdf is to have adobe pdf reader for android installed.(or concisely put, not possible in web view)

    0 讨论(0)
  • 2020-11-28 14:33

    I've found that the google viewer seems to work within the android browser for viewing online PDF files. You could build a link to your pdf so that it is displayed in the viewer. I've not tried doing that within a WebView though.

    UPDATE

    The link is dead, there is an explanation of how to get the functionality to still work at this link.
    In case this link also dies, here is the relevant section:

    While the page is no longer available as it redirects to Google Docs/Drive, you can still use the Google Docs Viewer. Paste this URL in a new tab:

    https://docs.google.com/viewer?url=

    and then paste the address of the document you want to view online. Here's an example:

    https://docs.google.com/viewer?url=http://research.google.com/archive/bigtable-osdi06.pdf

    0 讨论(0)
  • 2020-11-28 14:34

    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..

    0 讨论(0)
提交回复
热议问题