How to load PDF in webView from URL? - java

I am creating and Android app that fetches file url from Parse server and displays the PDF in webView with the help of Google preview, directly loading the PDF into the webView takes forever to load.
But the problem here is Google has a limit of 25mb i.e files larger than 25mb cannot be previewed and it gives a message "Whoops file size too large"
With Google previewer this is how the url looks:
https://docs.google.com/viewer?url=http://my.domain.com/yourPdfUrlHere.pdf
Is there any way to load PDF from URL and also displaying what has already loaded so that the users don't have to wait forever?
Thanks in advance..

webView.loadUrl("http://docs.google.com/gview?embedded=true&url=" + url);
This will concatenate your URL with Google Docs PDF Viewer and load it.

Related

Download PDF file for offline viewing

I'm trying to cache PDF files on the user's device and open them within my app at a later time.
With this package: https://github.com/barteksc/AndroidPdfViewer
I use pdfView.fromUri(uri) which loads the file from the URL every time the page is loaded.
Is there a function I can use to cache these files for offline viewing?
Download the PDF yourself, using your favorite HTTP client API. Then, use fromFile() rather than fromUri().

How to download an image on Android wear?

I have an ArrayList of Serialization objects on my handheld.
I found a solution to send it to my wearable device.
Can I send custom objects to Android Wear?
In my Object I have the URL of an image and in my handheld I am using Picasso to download the image from the URL (es in a ImageView).
Can I download the image in the wearable? (I think no).
Should I download all the images of the ArrayList in the handheld and send it putting them as assets in a DataMap?
You can't download images directly from the Wear as there's no direct internet access.
However you're on the right path by downloading images on mobile (e.g. using Picasso), then transferring them to the Wear via an Asset.
There's a tutorial with all the code required on how to send an image using an Asset in the Android training section:
https://developer.android.com/training/wearables/data-layer/assets.html

Download a pdf file from android application using Jsoup

I would like to download a pdf file from my android application. I want to download it using jsoup because I have to post username, password and cookies, so I have done it with jsoup. I have check the site adn saw that I have to connect at the login page and post: username,password,cookie and a variable next with the internal link of the pdf file. I have done it with jsoup but now I don't know how to download this file at my android device. I prefer, if it's possible, when it will download to appear on the notification bar of my device.
Thank you in advance!

Showing JFree chart image from local machine in a web application

I am generating a chart using JFree charting library. After generating it, I am saving it to the local machine(The requirement document specifically reads that I have save it in local machine).
Now there is an a drop down in the Web UI, to export the generated image to excel or to render the image in Web page itself.
Since I am saving the image in the local machine, the img src html tag, does not work.
Is there any way to get around the problem ?
Server used : Weblogic
You need to programatically read the contents of the file from the disk and serve it through some servlet using stream , and set the url of the Img tag in page to this servlet .

Downloading files via a webView

I am currently implementing a webview that uses the default behavior of opening the browser. When the page loads in the browser and I click the download link that is on the page that was loaded, the download starts, and quickly fails. I guess its an unsupported file type. How would I go about setting the WebView so that I may handle when a user downloads a file, and process the file myself? The reason I am going through a webview is that using httpclient, I was unable to spoof the headers after trying unsuccessfully for 30 or so hours. So what I would like to be able to do is handle the saving, and unzipping of the file myself. Can anyone write me some code to get started?
Thanks a million.

Categories