[TIMOB-25185] Android: WebView using data will not load PDF
GitHub Issue | n/a |
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Not Our Bug |
Resolution Date | 2017-08-27T13:40:37.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | n/a |
Labels | n/a |
Reporter | Joshua A. Ceaser |
Assignee | Unknown |
Created | 2017-08-21T20:13:14.000+0000 |
Updated | 2018-08-06T17:52:07.000+0000 |
Description
When attempted to render a PDF in a webview, if using the data property for the webview, the PDF will not display on Android. It will work on iOS>
Attachments
Hello [~jceaser], Android only supports loading data from a Blob, not a File. Please take a look this doc link http://docs.appcelerator.com/platform/latest/#!/api/Titanium.UI.WebView-property-data So you can check out the following links for the solution - https://archive.appcelerator.com/question/179830/open-a-pdf-file-from-remote-server-in-android#comment-223021 - https://gist.github.com/MotiurRahman/26bf43bb239533aa73e1 Thanks
Motiur Rahman, which is precisely why I'm passing file.read(). This should return a Blob http://docs.appcelerator.com/platform/latest/#!/api/Titanium.Filesystem.File-method-read. I believe there is still something wrong and I have tried your 2nd snippet and it does not work on android.
Hello [~jceaser], Currently, Android does not work like iOS in this respect. The WebView widget cannot display PDF documents on Android. You will have to: - Use a third party module for that - Open a pdf viewer app via an Intent - Use Google docs in a webview However, I am forwarding this to our engineering team if it is possible loading data from a Blob. Thanks
Native Android does not support opening local web-views, this is a platform limitation. Native discussions (like [here](https://stackoverflow.com/a/9434924/5537752)) suggest Google Drive open to it or open it as an Intent (supported by Titanium as well, more native experience). Other options are JS-libraries like pdf.js, but the web-view itself will not be able to handle PDF's until Android itself can. Here are some more links you can reference to: - https://stackoverflow.com/a/25481327/5537752 - https://stackoverflow.com/a/21493956/5537752
Closing as "not our bug". If you disagree, please reopen.