Hello I am trying to open a pdf file in Android .I am very new in Android .I have include PDF file in the project ..Now How can I open that pdf file on my first view.The PDF file contacts 20 pages.Should I open it in webview or there are some other options .Please someone can help me in this ??Its a very small help. Thans for your time.
2 Answers
There is no pre-built way in Android to view PDFs.
Here are your possibilities:
Use a third-party library
There are some free libraries, but most are GPL - so not for use in closed-source apps)
If you don't have to keep your app closed source, I'd recommend e.g. this library: https://github.com/JoanZapata/android-pdfviewUse Google Docs in a
WebView
like in this question.Handle the pdf to an external app for displaying. Just create an intent and set the data to your pdf path.
-
Do I have to use google docs..Is that necessary .I can't do like that .I have a webview on my first view and can load pdf in webview with some webview method. – rahul Jan 28 '14 at 19:56
-
There are only the three possibilities in my answer. – FD_ Jan 28 '14 at 20:01
In addition to the "only" three possibilities in FD_'s answer, there's actually a slightly different fourth, but it requires that you create your own web application. The idea is to send the pdf to a web service that reads it, converts it to images and sends the images back to the android device for display.
Of course you will need something to do the conversion on the web server, but you will have many more choices than doing the loading on Android itself, because the server can be anything.
I used this approach in a web application (HTML5) and my server was Windows & IIS with an SDK named Lead tools to load the PDF. I think they now have an Android sdk too but I haven't tried it.