Android PDF viewer app to be invoked - android

I need a pointer to a (preferably free) PDF viewer app that I can invoke on a file or URL link via a startActivity on an Intent. I know that there is no real standard - I have one phone that came with OpenOffice that can read local PDF files, and one phone that has no built-in PDF reader.
What I want is the name of an application that I can suggest to my users to download from the market that is a PDF viewer that I can invoke by configuring an Intent and calling startActivity. I would make this suggestion when I intercept a URL to a pdf file, and discover that the application is not yet installed. Although ugly, this is better than the blank screen they get now because the built in browser doesn't do PDF.
I already installed Adobe's PDF viewer but it is not showing up in the package manager as being a candidate to handle PDF files.
I have used the technique suggested in SO:how-to-render-pdf-in-android to examine the candidate activities for a URL based PDF link and a local file PDF link and see that the com.android.browser.Browser is always invoked for http:// URL links; a URL of "file.pdf" causes OpenOffice to be selected on one phone and nothing on the other phone. Adobe's PDF viewer is not a candidate for either approach.
I tried the Google Docs viewer approach (as suggested in SO:android-load-pdf-pdf-viewer but that leaves a lot to be desired, especially as the PDF image I tried to load kept moving further and further down the device's screen until a user would need to scroll several screen fulls of blank screen to get to the document.
I see libraries such as android-pdf-viewer as a potential solution. But I'd prefer to link to another application rather than build in PDF support (including the fonts, etc) into my application. This then allows my application to support multiple PDF viewer applications - choosing one that the user has already installed or suggesting my favorite one if no compatible reader is present when I need it. Potentially I could see using these types of libraries to create such an application and load it to the market place, but before doing that I want to make sure that I'm not re-inventing the wheel.
I found the droid-reader application which looks promising, but this doesn't appear to be available from the market place. While I'm personally comfortable with the gymnastics of downloading files to my sdcard and installing from there, its not a viable option for the general public user that I'm targeting.

I hope the following code snippit would be helpful to you for reading pdfs. It will use the default pdf viewer that has been set on your device.
Intent intent= new Intent(Intent.ACTION_VIEW);
File f = new File("/mnt/sdcard/file.pdf");
intent.setDataAndType(Uri.fromFile(f),"application/pdf");
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
getApplicationContext().startActivity(intent);

Related

Android Online PDF Load - Preview Not available error via Google Doc

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

Open attachements in PDF from mobile

I created a PDF with some files attached and links (in fact annotations) to these files:
When I open the PDF from my computer with Acrobat Reader I'm able to open all files either by clicking directly on the "Attachments" column or clicking on the links (annotations).
But when I try to do the same on mobile (iOS, Android or WP) via Acrobat Reader application (I also tried with Foxit App and few others) it doesn't work:
I can't access to the attachments column
When I clicked on the links (annotations) nothing happen
So, I want to know if someone know a mobile application (no matter of the OS) that is able to open/access to the attachments in a PDF ?
Thank you.
Gerald.
File attachments and other annotations are beyond the scope of most (if not any) mobile PDF viewer. You might have to look around to find a viewer which offers to support these objects; maybe you are lucky.
PDF viewers for mobile devices do evolve quite rapidly, so, things may change within the next few months…

Different way to open a PDF than from current SD?

I know there are many similar questions, but I need specifics. I originally wanted my app to open PDFS within the app itself, but I have settled to send an intent activity to adobe reader. I am currently opening PDFS by looking for the file on the device itself. Is there a way I can have the PDFS in my app, and create a folder on the users device, and then look for them? or something similar? Obvisouly the user isn't going to have the PDF already installed on their device. Here is my current code.
Intent intent7 = new Intent();
intent7.setPackage("com.adobe.reader");
intent7.setDataAndType(Uri.fromFile(new File("/storage/emulated/0/Download/Auto-example.pdf")), "application/pdf");
startActivity(intent7);
Is there a way I can have the PDFS in my app, and create a folder on the users device, and then look for them?
You can put the PDF in internal storage (e.g., getFilesDir()), then use FileProvider to serve them via a ContentProvider. This sample project demonstrates serving a PDF from internal storage (copied there from assets/) and viewing it in the user's chosen PDF viewer. There is also an Android training module covering this.
With respect to the code that you have, please use ACTION_VIEW as your Intent action (e.g., pass that to the constructor) and delete the setPackage() line.

Creating a PDF File reader in android

I'm developing an application to read PDF Files.
So, that my application itself has to read pdf Files. so which library is the best to show pdf files.
I have read a dozen of related articles but I couldn't get the idea.
There is a button on the front page, by clicking that button user gets access to sdcard. all the folders are under his fingers. on opening folders if user open .pdf file , it will open other wise a toast is shown, "this is not a pdf file".
It is hard to find a free and stable library. If you are opting for free try APV PDF Viewer
Make sure you read the license if you are planning of use it.
In one of my applications where I had to display pdf files inside the app, I used radaee pdf viewer. Easy to use, deals with fonts, and maybe stable.Problem is, it is not free. You can try it for free, but you will have a water mark in every page.
Hope this helps. Pdf in android app is not a walk in the park. I think that is the main reason that there are not tons of pdf viewers in google play. Good luck.

System call to open a pdf on Entourage eDGe's E-Reader

I am trying to write an app that requires different PDF files to be opened and displayed on the E-Reader side of the eDGe's dual screens while the app is running on the LCD side. I've been using Better Terminal Emulator to cruise around the eDGe's file system but can't seem to find the command that opens PDF files. Does anyone know it or is there even one?
I'm going to answer my own question in case someone runs into the same issue. Using an intent with the action set as ACTION_VIEW, the mime type set as application/pdf, and a pdf file as the data, the Library will handle the intent.

Categories

Resources