eclipsesource / tabris

Tabris for Eclipse RAP
https://eclipsesource.com/products/tabris
53 stars 18 forks source link

Android does not show PDFs embedded in Browser control #378

Closed JohnGymer closed 9 years ago

JohnGymer commented 9 years ago

I'm sure I asked this previously, but cannot find it anywhere, so I'm asking here! In Browser (RAP) and Tabris on iOS, a Browser control may point to a PDF file (usually we register these as RWT resources), and the PDF displays inside the Browser control. However, on Android the PDF never displays, and the Browser is always blank. Is this a limitation of the Browser control on Android? I note that if you point the Browser control to a PDF on an HTTP server, then Android will automatically open the PDF viewer App on the device to view the PDF, but not if it is an RWT resource. Is there any way to support embedded PDFs now, within an Android browser? Thanks, John

mpost commented 9 years ago

While i am not 100% sure i would think that the Android WebView does not support to open a PDF. Maybe you could refine your ui as to call out to the system (via the AppLauncher) with an url so that another app can handle the request.

This is taken from http://stackoverflow.com/questions/4947591/open-a-pdf-file-inside-a-webview

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

To view inside google drive.

JohnGymer commented 9 years ago

Thanks Moritz. I've handled it as a special case for Android, using AppLauncher, and building the full URL of the PDF file in rwt-resources (extracting hostIP, hostPort etc.) from the HttpRequest and launching that. Seems to work pretty well. Pity that the Android Browser control itself cannot embed PDFs though, but I realise this isn't under your control - you are just re-using the supplied control. Thanks, John