vanadium-archive / reader

Example app: PDF reader
BSD 3-Clause "New" or "Revised" License
3 stars 1 forks source link

[android] Render PDF files with PDF.js #44

Closed jxson closed 8 years ago

jxson commented 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"

/cc @yyoon

TODOS:

jxson commented 8 years ago

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

jxson commented 8 years ago

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