Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android PDF Rendering

I would like to render/open PDF file (stored in SDCard) in Android without using in-build application or viewer.

1) We have tried MuPDF open source library but rendering using this library is very slow.

2) Can we use iText library for rendering PDF files in Android (i.e. iText as a PDF Viewer).

Is there any other PDF library(open source) that can be used in Android Or suggest basic guideline for developing PDF viewer for Android.

like image 756
user895935 Avatar asked Aug 17 '11 02:08

user895935


People also ask

What is PDF renderer?

android.graphics.pdf.PdfRenderer. This class enables rendering a PDF document. This class is not thread safe. If you want to render a PDF, you create a renderer and for every page you want to render, you open the page, render it, and close the page. After you are done with rendering, you close the renderer.

How can I open PDF in android programmatically?

Opening a PDF file in Android using WebView All you need to do is just put WebView in your layout and load the desired URL by using the webView. loadUrl() function. Now, run the application on your mobile phone and the PDF will be displayed on the screen.


2 Answers

1) MuPDF is good to render textbook pdf in android while it may be slow to render pdf with big images. A lot of customizations and improvements especially memory usage control need to do if you want the MuPDF to run fast and stable on android platform. You can check out two open source projects VuDroid and apv which are based on MuPDF.

2) It's up to your requirements. The iText may be enough to render simple text pdf, but I don't think it has better performance than MuPDF or other libraries that developed by using C/C++.

Another choice is to use Poppler. A successful story is the popular android app ezPDF Reader is based on Poppler, although it's violating GPL license. The out of box Poppler needs more work than MuPDF to do to run on android smoothly. You can refer to the open source project apdfviewer.

like image 177
gluttony Avatar answered Sep 20 '22 12:09

gluttony


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).

like image 23
Luboš Staráček Avatar answered Sep 20 '22 12:09

Luboš Staráček