How to Open/Display Documents(.Pdf, .Doc) Without External App

How to open/display documents(.pdf, .doc) without external app?

I think you should use custom library for getting that done .See this and this

But there is a way for displaying PDF with out calling another application

This is a way for showing PDF in android app that is embedding the PDF document to android webview using support from http://docs.google.com/viewer

pseudo

String doc="<iframe src='http://docs.google.com/viewer?url=+location to your PDF File+' 
width='100%' height='100%'
style='border: none;'></iframe>";

a sample is is shown below

 String doc="<iframe src='http://docs.google.com/viewer?url=http://www.iasted.org/conferences/formatting/presentations-tips.ppt&embedded=true' 
width='100%' height='100%'
style='border: none;'></iframe>";

Code

    WebView  wv = (WebView)findViewById(R.id.webView); 
wv.getSettings().setJavaScriptEnabled(true);
wv.getSettings().setPluginsEnabled(true);
wv.getSettings().setAllowFileAccess(true);
wv.loadUrl(doc);
//wv.loadData( doc, "text/html", "UTF-8");

and in manifest provide

<uses-permission android:name="android.permission.INTERNET"/>

See this

Caution : I am not aware of compatibility issues with various android versions

In this approach the drawback is you need internet connectivity . But i think it satisfy your need

EDIT
Try this as src for iframe

src="http://docs.google.com/gview?embedded=true&url=http://www.pc-hardware.hu/PDF/konfig.pdf"

try wv.loadData( doc , "text/html", "UTF-8"); . Both works for me

Sample ImageSample Image

How open document pdf/docx with external app in Android

Try the below code :

 File pdfFile = new File("File Path");
Intent openPdf = new Intent(Intent.ACTION_VIEW);
openPdf.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
fileUri = FileProvider.getUriForFile(viewContext,com.mydomain.fileprovider, pdfFile);
openPdf.setDataAndType(fileUri, "application/pdf");
openPdf.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(Intent.createChooser(openPdf, "Select Application"));

Note : You need File Provider for granting URI permissions check this out

how to display online pdf file within app

It seems that library doesn't allow to display remote files.

Check this issue: Library does not support remote files, you have to download it by yourself.

You should download and store that PDF locally before trying to display it.

Display Word/PDF Document inside my Android Application

open pdf/Doc in webview

     String pdf = "http://www.pc-hardware.hu/PDF/konfig.pdf";
String doc="<iframe src='http://docs.google.com/viewer?url=http://www.iasted.org/conferences/formatting/presentations-tips.ppt&embedded=true'
width='100%' height='100%'
style='border: none;'></iframe>";
webView = (WebView) findViewById(R.id.webView1);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setPluginsEnabled(true);
webView.getSettings().setAllowFileAccess(true);
webView.loadUrl(doc);

Display PDF file inside my android application

Maybe you can integrate MuPdf in your application. Here is I've described how to do this: Integrate MuPDF Reader in an app

Android : how to open pdf file from server in android

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");


Related Topics



Leave a reply



Submit