Android PDF Rendering
I've done some research in this field recently, I've tried more than 14 libraries on Android, I've done simple benchmarking on some high resolution print-ready PDF magazines and I'm currently considering to use MuPDF or Radaee in work as they went out as the best.
I've tried VuDroid and apv as well and they are very unstable, they are crashing very often on complex PDF documents and very slow in comparsion to MuPDF or Radaee.
Since MuPDF and Radaee (and some other libraries) are written in pure C and are used on Android through NDK, they are giving the best possible performance (and they both are paid for a commercial use).
which library to use for displaying PDF file in application?
- Qoppa is commercial product
- muPDF is lightweight but GPLed
- iText is AGPLed, a tailored GPL v3.
- pdfBox is good but a bit big in size.
How to render PDF in Android
Some phones (like the Nexus One) come with a version of Quickoffice pre-installed so it may be as easy as sending the appropriate Intent once you've saved the file to the SD card.
public class OpenPdf extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button button = (Button) findViewById(R.id.OpenPdfButton);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
File file = new File("/sdcard/example.pdf");
if (file.exists()) {
Uri path = Uri.fromFile(file);
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();
}
}
}
});
}
}
Related Topics
What Does Transitive = True in Gradle Exactly Do (W.R.T. Crashlytics)
Why Can't I Use Resources.Getsystem() Without a Runtime Error
Reusing Views in Android Listview with 2 Different Layouts
Android - How to Change Fragments in the Navigation Drawer
Java: Need Some Way to Shorten This Code
Integration Testing Frameworks for Testing a Distributed System
Why Is Double.Min_Value in Not Negative
Authenticated Http Proxy with Java
Xmpp with Java Asmack Library Supporting X-Facebook-Platform
Networksecurityconfig: No Network Security Config Specified -- Android 7.0 Error
Android (Java) Simple Send and Receive with Server - Fast Setup Challenge
How to Create Button Dynamically in Android