Closed jxson closed 8 years ago
Explore the possibility of using a web view + PDF.js for a better rendering experience.
An initial idea is to use a WebResourceResponse to intercept requests for files and stream the data back to the client in the web view.
From the Android side:
@TargetApi(11) @Override public WebResourceResponse shouldInterceptRequest(WebView view, String url) { Log.d("shouldInterceptRequest", url); InputStream stream = new ByteArrayInputStream(source); if (stream != null) { return new WebResourceResponse("application/pdf", "binary", stream); } return super.shouldInterceptRequest(view, url); }
From the client we should be able to get the data into an array buffer by setting request.responseType = "arraybuffer"
request.responseType = "arraybuffer"
/cc @yyoon
TODOS:
@yyoon a good first step on this would to create an initial CL that can respond to requests for /test.pdf with a simple test file. From there we can split up the work between Java and JS...
/test.pdf
Initial JS is in CL#17902 a few small things that should be done to make the experience a little more robust (see TODO list above).
Explore the possibility of using a web view + PDF.js for a better rendering experience.
An initial idea is to use a WebResourceResponse to intercept requests for files and stream the data back to the client in the web view.
From the Android side:
From the client we should be able to get the data into an array buffer by setting
request.responseType = "arraybuffer"
/cc @yyoon
TODOS:
Serialize and store state so that it can survive page reloadsTemporarily locked screen orientation prevents reloads.Reload the page on debug toggles