Open local pdf file on webview - android

How can I open a pdf file from my android device(from download folder) on a webview? I tried to open pdf on webview but it supports only web url.Is it possible to open local pdf file on webview. I tried barteksc library, but it is a very large file. Any solutions?

I would suggest you use the native feature PdfRenderer instead of webview.
From android OS 5.0(lollipop) on-wards you can use this class to show pdf's within the app. If you want to support OS lower than that you can use a library as there is no native support
Read more about the class from the docs here, you can also refer this example provided by google

Related

View/display .doc,docx,xls files in Android programmatically

i am working on Document fatch app and i need to show .doc,.docx,xls files from my external storage to my app as i able to view pdf using pdf viewer but not getting how to show these files.
There is an android branch of Java library docx4j, you can use it. Another option is using Webview, set:
webview.getSettings().setPluginsEnabled(true);
webView.getSettings().setJavaScriptEnabled(true);
and then pass link of your document to webview (it can also be local link). I am not sure that webview solution will work on all versions of Android, so docx4j is more generic solution.

How to open pdf file with in our app android+phonegap+JQM?

I am developing an web+cross platform app using Jquery Mobile+PhoneGap+Android. In web app, I am able to open pdf file links within my app page using iframe. But, in Phonegap generated Android build, iframe is unable to render pdf content,it is showing that iframe area as empty.How can I display the pdf file/content, whose src I know at runtime, within android webview. Thanks In Advance.
I've just published my plugin, which can open almost any type of file, which is stored locally on Android device.
Please take a look at: https://github.com/markeeftb/FileOpener
Plugin opens external application which handles the preview of the document.

Use Phonegap ChildBrowser Plugin to view in App PDFs on Android

I have the childbrowser plugin installed and working on my Phonegap application. Works fine for websites but I want to instead view PDFs which have been stored in my assets file.
The link I have to the pdf is currently
Test
But when I do this it trys to navigate to
http://file://android_asset/pdf/Starting-Out_master.pdf
How can I change the link to view the prepackaged PDFs?
You cannot open a PDF using the ChildBrowser. You will need to use the PDF Viewer plugin. Here is a link, sorry that it is in Italian you'll have to use Google Translate or something similar.
http://www.giovesoft.com/2011/08/download-and-open-pdf-with-phonegap.html
Using the WebIntent plugin may also work. Most (but not all) Android phones come with a PDF viewer built-in, so letting the Android OS decide what application installed on the phone to handle the PDF file should work in most cases.
You could get the pdf file URI and open it with the childBrowser plugin's openExternal and let the native browser handle the PDF.

PDF Viewer Widget in Android

I have to provide the functionality of showing PDF docs in my app without using any external PDF viewer. I know Android doesn't have such kind of widget and WebView can't load a PDF doc.
So I want to know, is there any widget available which can be used to show the PDF docs in Activity (like WebView is used to show web pages)?
As I know, there is no such 'off-the-shelf' solution available for Android yet. You can of course download any third party PDF viewer's code and modify it as per your needs.
Some of the Open source PDF viewers:
IcePDF
DroidReader
This has already been covered at https://stackoverflow.com/questions/4665957/pdf-parsing-library-for-android
Another solution would be to use a WebView, but then use the pdf.js library to display a given pdf file. I doubt this would look very nice on a small mobile device since it's designed for desktop browsers, but its worth a try.
pdf.js website and demo

Android - Load PDF / PDF Viewer

I want to display pdf contents on webview.
Here is my code:
WebView webview = new WebView(this);
setContentView(webview);
webview.getSettings().setJavaScriptEnabled(true);
webview.loadUrl("URL/Demo_PDF.pdf");
Problem:
When i am trying to run the application, at that time I am getting blank screen.
And also, if there is any PDF viewer then also suggest me !!
FYI, I have already set internet permission.
Finally, i got a solution, actually i made a trick to load a pdf file using Google Docs inside a webview:
webview.loadUrl("http://docs.google.com/gview?embedded=true&url=http://myurl.com/demo.pdf");
I'm sorry but WebView does not display PDF content.
What you might want is a PDF viewer that responds to the PDF MIME type.
Here are a couple of free open-source libraries you might want to check:
droidreader
apv pdf reader
You can try using mupdf (www.mupdf.com)
You can build a native code library (libmupdf.so) to be loaded onto your android project using the ndk.
This would ensure a lot faster rendering of pdf files...
check out the project at : http://mupdf.com/repos/mupdf/android/
WebView does not have a PDF plugin. You should store the PDF locally and open an intent for viewing that kind of content.

Categories

Resources