Viewing PDF from URL using Adobe in Android - android

I'm just learning Android code and I've come upon a problem which I hope you can all help.
I want to display a PDF file from a URL from my application, I've got the PDF to display using a webView method however with having Adobe Reader and Polaris Office installed on my phone I was just wondering if I can load the URL and implement the PDF to be displayed using installed software?
My webView code is as follows:
WebView web = (WebView) findViewById(R.id.webView);
web.getSettings().setJavaScriptEnabled(true);
String pdf = "http://www.example-site.co.uk/pdf";
web.loadUrl("http://docs.google.com/gview?embedded=true&url=" + pdf);
I have searched several posts on here to no avail so any help will be much appreciated.

Searching for "pdf view intent" reveals stuff like that: How to render PDF in Android
If that doesn't help, you should try to implement a IntentChooser or directly ask the devs of your two apps on which intent they are listening.

Related

Whoops! There was a ...previewing this pdf document android

My application has a list of pdf inside listview. The pdf is viewed inside the application using a webview that open a Google Docs sheet. It works fine for the first opened PDF, but
when going back and opening another PDF I got the error "whoops! There was a problem previewing this document". Is there some kind of limitation on opening PDF using google sheet. If so, how can I get full rights to open any PDF I want. can someone help please. Here is my code.
//---you need this to prevent the webview from
// launching another browser when a url
// redirection occurs---
wv.setWebViewClient(new Callback());
wv.getSettings().setJavaScriptEnabled(true);
wv.getSettings().setJavaScriptEnabled(true);
wv.getSettings().setAllowFileAccess(true);
wv.loadUrl("https://docs.google.com/gview?embedded=true&url=" + SharepreferenceController.getPrefSavePdfInfo());
Try increasing the Version/Compatibility of the PDF. This worked for me.
Edit: I believe it is more of a size issue. When I changed the Version (from Acrobat 9.0 to 10.0) I had also optimized the PDF making it a smaller file. My larger files of the same Version still do not work.
I was having the same issue. What solved it for me was clearing the WebView cache before trying to load another PDF.
WebView webView=(WebView)findViewById(R.id.webView);
webView.clearCache(true);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl("https://docs.google.com/viewer?url=" + url);

android - Pdf link problem

My application has one button. If you click that button then it will display the web pages based on the web service response using webview.
It works properly for general links. But for links that have .pdf, a white screen gets displayed.
Is it possible to display the .pdf file using web view?
Would appreciate any help.
i used the following code
WebSettings webSettings = mWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
mWebView.loadUrl("http://docs.google.com/gview?embedded=true&url="
+"http://www.kim-lai.com/images/Menu_100309.pdf");
It sounds like it could be trying to but there is no direct pdf rendering support in webview. Please look at the following question
android webview pdf
You may find the following question useful also
how to open a pdf file inside a webview for android?
EDIT
Android - Load PDF / PDF Viewer
Please also make sure you ask appropriate questions, prefrerably with code so that others can reproduce your problem and offer a solution. Do your own research!!! Stack overflow is not a magic site that does your work for you!!!
ADENDUM
You require internet permissions. Add this to your manifest.xml
SUPPLEMENTAL
I tried typing in the url into the browser and it tells me "Sorry, we are unable to retrieve the document for viewing or you don't have permission to view the document. "
mWebView.loadUrl("http://www.kimlai.com/images/Menu_100309.pdf");
Try like this, what do you see?

How can i view pdf in android without pdf Application in device?

i want to view pdf file from internet..can anyone tell me how can i view??
Please Use This code For view Online PDF without Using PDF of Application
mWebView.loadUrl("http://docs.google.com/gview?embedded=true&url=http://your_link/634128127095123576.pdf");
WebView webview = (WebView) findViewById(R.id.webview);
webview.getSettings().setJavaScriptEnabled(true);
String pdf = "http://www.adobe.com/devnet/acrobat/pdfs/pdf_open_parameters.pdf";
webview.loadUrl("http://docs.google.com/gview?embedded=true&url=" + pdf);
Please view this answer for more details: how to develop a pdf reader in android
But please be aware that webview does create some extra threads like Cookie Manager and history manager , it might just increase your memory foot print a bit. I saw this behaviour when i looked at threads created in Eclipse ADT plugin

PdfReader in Android

I have to develop an application which reads pdf file in pdf format and only pdf file should be read in the application.I wanted to know one more thing is it possible to use itext.jar for
the android application.
Developing an PDF reader for Android is not really simple, so I suggest you read this PDF file online by Google Docs Reader
WebView webview = (WebView) findViewById(R.id.webview);
webview.getSettings().setJavaScriptEnabled(true);
String pdf = "http://www.example.com/example.pdf";//url to pdf file
webview.loadUrl("http://docs.google.com/gview?embedded=true&url=" + pdf);
This may not be the thing you want, but still hope it helps you someday.
However some Android PDF APIs are http://code.google.com/p/android-pdf/source/browse/#svn/trunk/src/org/broncho/pdfreader and http://andpdf.svn.sourceforge.net/viewvc/andpdf/trunk/AndroidPdfViewer/src/com/sun/
You can also look at an SO discussion on the same problem Android PDF reader from scratch
You can use one of the opensource PDF readers (eg: XPDF) and compile it for Android.

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