开发者

Display PDF in Android - loaded from external, authenticated URL

开发者 https://www.devze.com 2023-03-21 11:24 出处:网络
In my Android app, I need to display a PDF file. The PDF file is read directly from the web, through an API that uses basic authorization (I\'m using the Apache HttpClient with a line like request.add

In my Android app, I need to display a PDF file. The PDF file is read directly from the web, through an API that uses basic authorization (I'm using the Apache HttpClient with a line like request.addHeader("Authorization", "Basic " + Base64.encodeBytes(username + ":" + password).getBytes());)

I've looked through some related questions and the answers seem to either suggest:

  • saving the PDF as a file on the SD card then displaying with some other library, like Apache PDFBox (certainly possible, but adds a 9.8MB library to the app and the hassle of file IO).

  • displaying the PDF through a WebView by passing the URL through the docs.google开发者_StackOverflow.com reader (can't use this approach due to authentication constraint).

I'd be really keen to hear of any possible solutions on this one, thanks!

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号