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.
Related
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
Is there a free way to view postscript files on android? I cannot find a solution online but surely lots of people must want to do this.
Recently Sam Buss and I realized that you can upload the PS file to Google Drive and once its uploaded to your drive, the drive viewer will open and render the PS file on your android device.
Here is a way that just worked for me on a Samsung Galaxy 5. Something similar can probably work for others. The general idea is to download the postscript file, and use an online web service to convert it to PDF, which you can then view.
Download the postscript file.
Open your browser (I use Chrome). Navigate to www.ps2pdf.com. Navigate your way to their "Convert" page, click the "Choose file" botton. Select "Documents" when it asks for "Choose an action". Go into your "Downloads" folder on your phone. Select the downloaded postscript file. Then, back on the ps2.pdf.com page, click the Convert button.
Click the active link for the converted PDF file. This opened in Adobe Reader, which is my default PDF viewer). If I want to access the file from other programs, it is in Adobe Reader's "Recent" folder in my phone's documents.
I want to show a pdf (preferably) or a word document in my app; like a privacy notice screen. Many applications have it, so it should be possible. i tried loading a simple text file as a start but doesn't provide formatting, fonts or trade mark symbols. I've gone through a few posts but I couldn't apply it to my app. Could anyone tell me how is it done? Could I store the file somewhere in res folder and provide a path to open it through my code? I looked into the following link but I'm not sure if that's the right approach in my case android: open a pdf from my app using the built in pdf viewer.
Android does not support opening PDF and DOC files natively. You'd have to make your own implementation.
Like t0mm13b said, you should consider using HTML (+ CSS) instead and use a WebView.
I'm trying to create an activity to show information about the monuments. What I thought is to create HTML files and then display them with a WebView. The problem is that I also need to export these contents on sdcard in some type of readable format (preferably pdf but I read some things and it seems very difficult and then I tried several solutions without success). How can I do this? Should I start from another type of format different from HTML?
Advise me a path to follow ... I do not know what else to try.
Thanks in advance. :)
Michele
There are multiple options. I would suggest go the PDF way.
If you have control over the contents, then the best way would be to create PDFs and you can then send a intent to open the PDF. If there are multiple PDF viewers available, then the intent will give an option for the user to select the viewer. If there is only one viewer available, the PDF will be opened in the viewer. If there are no available options, you can then send them to Google Play (Android Market) to download a PDF viewer and then view the PDF.
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);