Android : how to open pdf file from server in android

10,789

Solution 1

you have to try this code for open a pdf file in your application..

WebView webView = (WebView) findViewById(R.id.my_webview);
webView.setWebViewClient(new MyWebViewClient());
webView.addView(webView.getZoomControls());
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl("http://docs.google.com/gview?embedded=true&url=http://myurl.com/demo.pdf");

Solution 2

   String pdf = "http://www.xyzwebsite.com/yourfile.pdf"; //YOUR URL TO PDF
   String googleDocsUrl = "http://docs.google.com/viewer?url="+ pdfurl;
   Intent intent = new Intent(Intent.ACTION_VIEW);
   intent.setDataAndType(Uri.parse(googleDocsUrl ), "text/html");
   startActivity(intent);

Add this permission to manifest file

<uses-permission android:name="android.permission.INTERNET" >
Share:
10,789
Preet_Android
Author by

Preet_Android

I'm an Android application developer. My working area is Java, Android and phone gap. I have developed more than 30 Android Application in which more than 20 is live on Google Play store. My Phonegap application are also live on Google play store as well as on iTunes(apple store). My technical skill are Java, Android, Phone gap, Oracle DB, MySQL, SQLite, HTML5, XML, javascript, jQuery and JSON. Thanks Happy Coding!!!

Updated on June 05, 2022

Comments

  • Preet_Android
    Preet_Android almost 2 years

    I'm new to android programming and I'm developing an application in android to open a PDF file from a server in my app. I've no idea about that. So please help me. How i can do this?

    Thanks in advance.