I know this may be a long shot, but I'm building a fork of Android Chromium and trying to find a way to support viewing PDF files from external sites in-browser, without downloading the file.
It's a strict business rule that the PDFs cannot be stored on the device.
I've noticed that mobile Safari on iOS devices does something similar to this and shows the PDF in-browser.
I have found this post which is helpful, but does not necessarily help me with the fact that I do not control what the external site hosting the PDF does.
Any help would be greatly appreciated.
Related
We have a file server on which we place PDF documents and then embed links to them in a smart device app. Up until recently, using links to the PDF documents starting with http:// worked fine for Android and iPhone users. All could load the PDF file just fine. Then a few months back (approximately) Android phone users started reporting they would get an error when trying to load any PDF. Yet iPhone users had no issues loading the same PDF document. It was verified that these PDF documents (several) were not corrupted and opened fine when placed on another file server.
I have an iPhone so I can't give you the exact error msg received by Android users but to reproduce it, it was along the lines of... click the link to the PDF, a button appears showing View PDF, click that button and several apps appear to choose the app to open the PDF with, click one (like Adobe Reader, or Google Drive) and an error appears stating the file could not be opened and may be corrupted of the wrong syntax.
Tonight I found the solution.
The url to the PDF on all these documents on our server had been like http://...
but when I changed it to https://... it works fine.
I can't find ANYWHERE any mention of a change by Google that this is now a requirement.
My question...
Can someone explain and/or point me to a reference that explains why https must be used in embedded links to PDF documents? It seems like a pretty big deal to make this a requirement and not tell anyone. My searching the internet has so far not turned up anything.
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 have a doc/ppt/xls file located in my sd card. I want to open it without any third party app (i.e within my app itself) using webview. Though I am able to open documents by embedding it in google docs url like -
http://docs.google.com/gview?embedded=true&url=[filelinkHere]
But how to open a file located in internal or external storage in webview ?
Also, Suggest me any third party ALL-IN-ONE library for android to view all types of documents. I have tried ASPOS but it has few unresolved bugs and APACHE-POI is difficult to use.
I had the same issue few days ago .
i found Android PdfViewer best to view PDF files and Android PdfMyXml best to create pdf files in android.
For working with Word and Excel as a most reliable answer I suggest you to take a look at OliveDocLibrary .
If your documents are in cloud so there is an alternative way to display docx,pptx,pdf and such formats with a combination of Webview and googleDoc.
You might find other possible solutions in server-side machines or maybe a creative way!
Hope it help
You can integrate some library project to your project with which you can open the pdf file inside your app.
Reference :
https://github.com/tekinarslan/AndroidPdfViewer
https://github.com/JoanZapata/android-pdfview
I have a website caching pdfs offline with a .manifest-file.
On the desktop version of Chrome the PDF can be viewed offline inside Chrome. But on the Android Chrome nothing happens when I'm trying to open the cached PDF. No error message, just nothing.
I'm guessing the android default pdf-reader can't find the cached pdf?
Anyone who knows how I can view the PDF in Android Chrome?
Thanks!
That's correct, browsers differ in terms of their built-in PDF support. One method you could explore is using Mozilla's pdf.js, which is a pdf reader built entirely in javascript that works just about everywhere. Make another web page that calls pdf.js and loads the PDF, and make sure all of that is in your cache manifest and you should be good to go.
Am looking for the way to play video inside my android browser locally. There may be two or more video's in a local page (like facebook contains video's).
Can anyone please help me out..
Without actually reading about the specifics of the Android built in browser I would safely say, you can't. Well, if you run a local html file it might work, but if you intend to have an external page from which you can play local videos it shouldn't work. I say shouldn't because in the early days of browsers some of them actually did give you access to the local file system. Javascript for example could use file://, something I used myself for image previewing before upload. But this was a major security concern and all modern browsers prevent this.
The difference is if you run a local file or a file on your own local web server. Since then, your local file system is actually part of the web servers file system and the web server can serve your local files.