Kyle Banks

How To Load a PDF in an Android WebView

Written by @kylewbanks on Mar 6, 2013.

Unfortunately, Android does not support viewing PDFs out of the box in a WebView. Luckily, Google has a nifty little tool that allows you to perform this very task quite easily using Google Docs. Basically we will embed our PDF in a Google Doc page on-the-fly and load that. Here's the code:

String myPdfUrl = "";
String url = "" + myPdfUrl;
Log.i(TAG, "Opening PDF: " + url);

Simply replace the myPdfUrl value with your own remote PDF, and you're done.

Let me know if this post was helpful on Twitter @kylewbanks or down below, and follow me to keep up with future posts!