Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-25185] Android: WebView using data will not load PDF

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionNot Our Bug
Resolution Date2017-08-27T13:40:37.000+0000
Affected Version/sn/a
Fix Version/sn/a
Componentsn/a
Labelsn/a
ReporterJoshua A. Ceaser
AssigneeUnknown
Created2017-08-21T20:13:14.000+0000
Updated2018-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

FileDateSize
webview-pdf.zip2017-08-21T20:13:06.000+00007084187

Comments

  1. Motiur Rahman 2017-08-22

    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
  2. Joshua A. Ceaser 2017-08-22

    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.
  3. Motiur Rahman 2017-08-22

    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
  4. Hans Knöchel 2017-08-27

    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
  5. Eric Merriman 2018-08-06

    Closing as "not our bug". If you disagree, please reopen.

JSON Source