View PDF on your phone

I am looking for a PDF viewer for Android using Phonegap 2.0. I tried the childbrowser plugin that worked on iOS but not on Android. I tried this http://www.giovesoft.com/2011/08/download-and-open-pdf-with-phonegap.html , but it didn’t work either, I get error messages such as PhoneGap is not set in the file And it cannot call the "showPdf" method undefined.

Hope someone can help me.

Thanks in advance!

+8
javascript android html cordova
source share
5 answers

you can use pdf.js:

pdf.js is an experiment with HTML5 technology that explores the creation of a reliable and efficient portable document format (PDF) without native code support.

https://github.com/mozilla/pdf.js

+3
source share

I already answered a similar question (see Open PDF using PhoneGap in Android ), but will do the same here. Use the ChildBrowser plugin as suggested in conjunction with Google Docs, for example:

onclick='window.plugins.childBrowser.showWebPage(encodeURI("http://docs.google.com/viewer?url=' + pdfLink + '")); 

This works great for me, and I tested it on Android 2.1 to 4.1.

+1
source share

The childbrowser plugin I tried does not open the PDF file on the Android phone. However, it works for iOS. Another solution for your plugin might be to use Open With plugin. There is one drawback that this plugin does not open a PDF file in the application itself. You can use the bootloader plugin to download files, and then try out the childbrowser plugin to access this PDF file, which I think should be the solution

0
source share

In Android, you can view pdf files using Android Intents. This will show you all the pdf views available on your phone. You can choose any and view PDF

For example:

 private void showPdfAndroid(String url) throws IOException { Intent intent = new Intent(); intent.setAction(android.content.Intent.ACTION_VIEW); File file = new File(url); String extension = url.substring(url.lastIndexOf(".")+1); String type = ""; if (extension.toLowerCase().equals("pdf")) { type = "application/pdf"; Log.d("application/pdf", "application/pdf"); } intent.setDataAndType(Uri.fromFile(file), type); cordova.getActivity().startActivity(intent); Log.d("FileViewerPlugin", "View complete in" + url); } 
0
source share

The child browser does not support viewing PDF in android. better you use google doc viewer for it in android. here, in another question , you will get the full answer

0
source share

All Articles