We have a serious problem to tackle here. We are loading pdf documents as binaries into our application and need to be able to view them. Due to security reasons we are not allowed to store them on an external storage.
Our investigations showed that adobe reader x does not support handling binaries and can only digest physical links to a document. This means, it is not an option for us.
Is it correct that Google does not provide a native API to view PDF documents? We could not find any evidence.
Only option left is to implement either our own pdf viewer activity or integrating an existing library.
Are our findings correct? If so, could somebody point out a suggestion on how to proceed here? Are there any ressources available enabling us to implement our own viewer?
We are currently looking at using: http://code.google.com/p/apv/
You can use this: http://www.adobe.com/devnet/readermobile.html. RMSDK supports everything that Adobe Reader built on top of it supports. Though, I wonder why the security? Why can't you generate password protected PDFs or livecycle protected ones? What is there to stop people from stealing your 'binary' (PDF document).
Is it correct that Google does not provide a native API to view PDF documents?
Yes it is true
We could not find any evidence.
Run a search yourself
Are there any resources available enabling us to implement our own viewer?
Besides the one you've shown there is andpdf
You can try searching if there is an application supporting pdf viewing on the phone. Some phones like Nexus supports this.
Uri path = Uri.parse("android.resource://com.your.app/raw/pdfId");
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(path, "application/pdf");
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
try {
startActivity(intent);
}
catch (ActivityNotFoundException e) {
// no apps with pdf support, run your own
}
Related
English is not my strong language, but please bear with me.
What is the difference between a PDF Reader and a PDF Viewer ? Some apps and api uses these terms and got me confused.
My second question is, I dont understand how GPL works. From what I read on these libraries like MuPDF, vuDroid, APV, it is free to develop but I have to buy a license to commercialize my app. How does it work if I were to publish my app on the Play Store for Free ? I dont get this, does publishing my app = commercializing ?
My third question, I understand that I am required to publish my source code should I use any of the mentioned libraries due to GPL license, but do I have the option of not publishing my code at all ?
What I want is just to create an app that is able to open a pdf file in my app. Something like an eBook app.
Well, PDF Reader and PDF Viewer are the same - they are both types of programs used to read (=view) pdf files.
If your app is published on app store for free, then its not commercial app, so publishing your app on appstore is not the same as commercializing it.
BTW - Most android users have some kind of program for viewing PDF files pre-installed, so you can just open PDF viewer with intent like this:
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(path, "application/pdf");
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
try {
startActivity(intent);
}
catch (ActivityNotFoundException e) {
Toast.makeText(OpenPdf.this,
"No Application Available to View PDF",
Toast.LENGTH_SHORT).show();
}
If you want to view PDF files directly in your app (which is probably what you want to do) you can use libraries like you mentioned.
EDIT: If you use GPL library, i think your application also have to be GPL (see GPL License in closed source application), but you dont have to buy license.
I know this question has been asked several times but I couldnt find one satisfying answer.My requirement is simple.just to open the pdf docs within my app(android).But I am not able to find a simple way of doing this.either its native c/c++ way or writing your own engine.But isnt there any simple API so that I can include it like a jar and view the pdf?
No. There is no API in the Android SDK to natively display PDF.
Solutions I can suggest:
-Use an external application:
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(path, "application/pdf");
startActivity(intent);
-If your PDF document is accessible online, use the Google Docs Viewer to open your PDF in a WebView:
http://docs.google.com/viewer?url=http://mypdf.pdf
you can use native plugin to show the PDF within your app. try this apv
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);
Does android provide any built it control like video view or image view to display pdf ebook?
More specifically I want to open a pdf ebook in android with following controls on the screen.
zooming controls
turn over functionality/swipe to change page.
What is the suitable way to achieve this?
Android does not provide a default PDF reader. I believe some phones come with a pre-installed application for reading PDFs, but you cannot rely on this fact for all devices. The best you can do for now is choose to open the user's default PDF reader (if they have one installed).
Use an intent to open up the user's default PDF app (untested, should be something like this):
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(pathToPDF, "application/pdf");
startActivity(intent)
I am new to android programming, so i have a question regarding how to open any document such as .doc, .docx, .ppt, etc. in android. I also need to implement preview functionality, wherein the file should be downloaded temporarily and user can see the file opened just by a single click.
How does dropbox does this? Is there any intents available?
Can anybody help me out of this issue by some example or code?
Thanks.
Unlike iOS, Android itself does not support rendering .doc or .ppt files.
You are looking for a public intent that allows your app to reuse other apps' activities to display these document types. But this will only work for a phone that has an app installed that supports this Intent.
http://developer.android.com/guide/topics/intents/intents-filters.html
This may help: Android Launching an application chooser with appropriate list of applications