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
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 already shown a PDF file in android device. But I need to scribble (writing with my finger) in that PDF page and I need to save the changes with existing PDF file itself in the sdcard. I searched so many source codes but i can't get what i am expected. Could you anyone help me on this. Thanks.
I am working on android applications. I gone through the link http://dhruvvaishnav.blogspot.in/2013/05/download-file-to-your-android-device.html and able to display the pdf file. But now my problem is with security. When I display the pdf file in my android application it is possible to save that file. But according to my requirement the pdf file should not be saved. It should be only readable and should not be savable. What is best solution for this?
Please anybody help me with this issue.
Thanks in advance
Can someone please point me in the right direction. I have been googling for ages and I'm not getting great results.
I want my app to allow the user to download a file from the USB/SDcard. Specifically an image, which then later gets used in my app.
I can't seem to find anything, been searching for open file dialogs and nothing..
So:
1) User inserts USB device/SDCard.
2) User gets file browser dialog.
3) User finds image from USB/SDCard
4) App grabs image and stores it for later use.
Thanks :)
I think what you are looking for is how to work with external storage in Android. there is a very good tutorial from android site: http://developer.android.com/guide/topics/data/data-storage.html#filesExternal. hope this helps.
To browse for images on the SDCard this thread is very helpful:
How to pick an image from gallery (SD Card) for my app?
I would suggest using the Android Gallery interface for images as it is much easier for the user than browsing files.