I'm looking for a way to display a pdf that is loaded in a webview.
The case is as follows:
- We load a (external) web application inside a webview.
- The web application is secured, users have to login to access their data.
- When the user has logged in there is a button for downloading a pdf file.
- On iOS the pdf file is being displayed inside the webview, on Android it isn't.
- It is not possible to access the pdf by using a webservice instead of the webview (so, Titanium.Network.HTTPClient cannot be used)
We tried several solutions that we found on the internet. Unfortunately, till now without any success.
We tried:
- Google's documentviewer: http://docs.google.com/viewer?embedded=true&url=. This is not working because the pdf is 'behind' a username/password. Google is not aware of the session.
- Saving the pdf to the local file system and open it with Android Intent. We did not succeed in saving the pdf on the local filesystem.
The last option (saving the pdf and open it by using Ti.Android.Intent) seems to be the best option. But is it possible to save a pdf from a webview???
Maybe an external module (or using pdf.js) is also an option.
Can someone point me in the right direction.
We even don't know if what we want is possible?
Any help is really appreciated.
Stefan.
Related
I have the below tag in my website for downloading image
<a href="data:image/png;base64,%20iVBOdfd...." download="myimage.png" />
The above tag is working normally, when it is pressed, it will download the image without any issue.
When I tried this function on ios / android, the web browser will download the image to some "Download" folder instead of writing it to camera roll (IOS) / DCIM (android).
My question is, is it possible to write to camera roll or DCIM? If it is possible, how can I achieve it? This function is crucial to my application as my users always find it hard to navigate on phone to retrieve the downloaded images at later time.
P.S: My concern is more about the writing destination, filesystem access on phone, not the download itself.
P.S: this is a normal website written using html, vuejs. not native, not react native, not vue-native.
Thank you.
That is not possible since it is the web browser who has access to the device and your web application cannot decide where to save the image. You'll need to implement an app to achieve the expected result. Also study Progressive Web Apps to see whether it's possible
I am trying to create an app that will be able to display a pdf file in the app itself. I'm currently using the Xamarin.Bindings.PDFView-Android by SIDOVSKY which works really nicely. I can open a file easily from the assets... what I'm struggling to do is open a file from the internet.
Just a single line of code:
FindViewById<PDFView>(Resource.Id.pdf_view).FromAsset("report.pdf").Show();
Is enough to display a PDF that can be pinched to zoom which is great. However, I now want to access a file stored on the local network. Either using a SMB share, or through the intranet. Whichever way I try I can't figure it out.
There is a .FromFile setting, but I can't get it to work by putting a smb path in here. Is there a way to convert this? Or must I download the file to the local device first?
Thanks
Andrew
Im new with Android. My task is to create a mobile application based on a responsive WordPress website. I would like to be able to download some of the content of this site. Website uses HTTPS. In the first, most primitive version, I tried to use WebView. I wanted to use the following: WebView load website when online, load local file when offline. Unfortunately, only the white page appeared and nothing more. In the case of "Google.com link" a page has been loaded in an external browser (Oreo Android).
Any suggestion how should I start? The easiest way would be to download an HTML page or have access to files on the server. Unfortunately, I do not have that access.
As always -1 without even trying to help....
As I said load from cache when Internet is disabled not working. Work only WebView (without login, because CORS). So how should I face it?
The core part of my application is load PDF online and user have access to download it as per their given rights.
The problem I am facing is that I want to load pdf online. After many research I have found that,
There are likely two ways to show pdf online in android:
1) In Web view by loading simple hosted URL
2) By google doc.
But in our case, if we use way (1), the mobile web view does not redirect hosted url of PDF.
And if we use way (2), then there are certain limitations of the google docs regarding the file sizes. (Small pdf it will load like 5 to 10 with size of 1MB)
But after loading PDF with the size of 2 or 3 MB it's also giving me error as "No PREVIEW AVAILABLE" and its continuously giving me this error opening different urls.
So it seems there is still no easy solution for viewing a pdf from url (online without downloading pdf).
The other way to open pdf online is that we can open it in any other third party applications like browser, adobe pdf reader or any kind of pdf viewer application available in the device.
Cons: If we open pdf in browser then it will get downloaded automatically and if we open it in any third party application then they have options to download the pdf.
Please give me some solution to read the PDF online.
And if there are any paid pdf SDK availble which gives functionality of loading pdf online from URL, then please provide information of that too.
Please also suggest me some pdf viewer library for displaying pdf online.
I have used many of the library, but it increases my application's size to 8 to 10 MB.
Thanks in advance.
The suggested primary solution,
Download the file, store it in the app specific folder so users don't have access. For viewers who don't have access rights to download it, you will delete the file as they leave the view. For viewers who have access rights to download it, they will be given an option to copy the file to their SD card (an accessible location) and then you will delete the original file as they leave the view.
For storing in app specific directory to restrict user access,
http://www.grokkingandroid.com/how-to-correctly-store-app-specific-files-in-android/
Also use a library to view the pdf(MUCH SIMPLER), choose an appropriate one from here
https://android-arsenal.com/search?q=pdf
Alternate solution,
If security is a major concern, you can encrypt the pdf file and store it on the server. And decrypt the file when you download it to the device.
For added security, don't store the file as pdf, just store it as a file. Download it as a file. Set type as pdf when you want to access it.
Conclusion,
Data wise, Even if you load it online, the device will consume almost same data as downloading the pdf. (Infact for viewing something online, your device downloads the data and stores it in the cache and you can view it)
Security wise, only a rooted phone will be able to access the file but that too for as long as you have decided to store it.
I suggest you check out PDF.js, a Javascript library from Mozilla to render PDF's in a browser. You can adapt this into a WebView easily, and display PDF's without downloading them.
Here is an open source app which does something similar to what you're looking for
I am working on an application where I load few websites in webview now I want to save webpages so after sometime even if there is not internet user will able to see those pages. But I am confused on how to save whole webpage in cache or any other medium. The main thing is we need to show pages back even if there is not internet.
Has anyone implemented this before. Please provide some demo code as this is my first attempt on cache..
Thank You
The easiest way is save webpages in cache directory or any other(Internal or external storage)
You can get the data of web page using HttpClient.execute() or HttpClient.get() now store that data in .html file also you have to download images or other contents which are bind to that page, Now in your application you have to check for connection if connection not available then load the page which one you saved in storage with file://<location of your webpage..>
EDIT:
I think using HTML5 you can display off-line webpages. (I never tried this, but I referred some blogs on it). Look at this nice post about HTML5 Creating mobile Web applications with HTML 5, Part 3: Make mobile Web applications work offline with HTML 5 Also this
hope this will help you.