MacOS X has PDFKit which in turn has PDFView. What other operating systems support viewing PDF files natively?
Android does not have a built-in PDF presenter. However, I found a workaround. Have a look at this thread. I extended the PdfViewerActivity in order to present a PDF file. It works pretty nice.
Snippet:
Intent intent = new Intent(CurrentActivity.this, ExtendedPdfViewerActivity.class);
intent.putExtra(PdfViewerActivity.EXTRA_PDFFILENAME, pathToPdfDocument);
startActivity(intent);
Related
I am developing a Cordova Android and iOS application. I am downloading multiple format of documents in my app like PDF and HTML.
I need to open these document from my app. Is there any way to call a default PDF application or other application that support the format of the document from my Cordova application?
I know that the final resolution is to write my own implementation to read the documents using 3rd party libraries.
UPDATE:(Another plugin option)
IF you have similar requirement. Have a look at
https://github.com/pwlin/cordova-plugin-file-opener2
This plugin supports both iOS and Android
If you have to try out with external FileOpener library then i think it will works.
Try this link :- https://github.com/markeeftb/FileOpener
Hope it will helps you.
You can achieve this in Android as follows:
Uri fileUri = Uri.fromFile(file);
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setData(fileUri);
startActivity(intent);
If you are handling multiple file types, use Intent.setType
You can use MimeTypeMap.getMimeTypeFromExtension to get the type you need to set in the Intent.
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
}
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)