Best Android PDF Libraries 2019

Best Android PDF Libraries in 2018

PDF stands for Portable Document Format. It’s a file format developed in the 1990s to present documents, including text formatting and images, in a manner independent of application software, hardware, and operating systems.

PDF was first released 24 years ago in the year 15 June 1993 by Adobe, however is now an open standard maintained by the International Organization for Standardization (ISO).

There are plenty of free and commercial PDF Reader applications for android devices. However, we as developers should build our own little pdf readers that maybe we and our friends can use.

It’s not as difficult as you would think and several open source libraries exist to aid in this.

In this piece we will look at some of these libraries and probably snippets of how to use them.

Let’s start.

1. AndroidPdfViewer

This is an open source libary
for displaying PDF documents.These PDFs are rendered with PdfiumAndroid.

AndroidPdfViewer is currently the most popular Android PDF View library. It’s maintained by bartesk and he has released various versions of the library independently.

For example, alot of people are still using AndroidPdfView, yet there is a AndroidPdfViewV1 and AndroidPdfViewV2.

This library has support for animations, gestures, zoom and double tap support.

Using this library is easy, very easy.

First you just include it in your app level build.gradle:

compile 'com.github.barteksc:android-pdf-viewer:2.8.2'

Then in your layout:


Then you can load the pdf from various sources:

pdfView.fromStream(InputStream) // stream is written to bytearray - native code cannot use Java Streams
    .pages(0, 2, 1, 3, 3, 3) // all pages are displayed by default
    .enableSwipe(true) // allows to block changing pages using swipe
    // allows to draw something on the current page, usually visible in the middle of the screen
    // allows to draw something on all pages, separately for every page. Called only for visible pages
    .onLoad(onLoadCompleteListener) // called after document is loaded and starts to be rendered
    .onRender(onRenderListener) // called after document is rendered for the first time
    // called on single tap, return true if handled, false to toggle scroll handle visibility
    .enableAnnotationRendering(false) // render annotations (such as comments, colors or forms)
    .enableAntialiasing(true) // improve rendering a little bit on low-res screens
    // spacing between pages in dp. To define spacing color, set view background
    .invalidPageColor(Color.WHITE) // color of page that is invalid and cannot be loaded
View Download
View Direct Download

2. PdfiumAndroid

The same author of AndroidPdfViewer, bartesk forked PdfiumAndroid from it’s original repository and has been maintaining and added some documentation as well.

The original PdfiumAndroid hasn’t been maintained.

So the [forked version(] has some documentation and is being actively mainatinaed.

He forked it so as to use it with the popular AndroidPdfViewer.

However you can use it independently as well.

First you’d need to add it as a dependency:

compile 'com.github.barteksc:pdfium-android:1.8.2'

Then here’s a simple example:

void openPdf() {
    ImageView iv = (ImageView) findViewById(;
    ParcelFileDescriptor fd = ...;
    int pageNum = 0;
    PdfiumCore pdfiumCore = new PdfiumCore(context);
    try {
        PdfDocument pdfDocument = pdfiumCore.newDocument(fd);

        pdfiumCore.openPage(pdfDocument, pageNum);

        int width = pdfiumCore.getPageWidthPoint(pdfDocument, pageNum);
        int height = pdfiumCore.getPageHeightPoint(pdfDocument, pageNum);

        // ARGB_8888 - best quality, high memory usage, higher possibility of OutOfMemoryError
        // RGB_565 - little worse quality, twice less memory usage
        Bitmap bitmap = Bitmap.createBitmap(width, height,
        pdfiumCore.renderPageBitmap(pdfDocument, bitmap, pageNum, 0, 0,
                width, height);
        //if you need to render annotations and form fields, you can use
        //the same method above adding 'true' as last param


        printInfo(pdfiumCore, pdfDocument);

        pdfiumCore.closeDocument(pdfDocument); // important!
    } catch(IOException ex) {

public void printInfo(PdfiumCore core, PdfDocument doc) {
    PdfDocument.Meta meta = core.getDocumentMeta(doc);
    Log.e(TAG, "title = " + meta.getTitle());
    Log.e(TAG, "author = " + meta.getAuthor());
    Log.e(TAG, "subject = " + meta.getSubject());
    Log.e(TAG, "keywords = " + meta.getKeywords());
    Log.e(TAG, "creator = " + meta.getCreator());
    Log.e(TAG, "producer = " + meta.getProducer());
    Log.e(TAG, "creationDate = " + meta.getCreationDate());
    Log.e(TAG, "modDate = " + meta.getModDate());

    printBookmarksTree(core.getTableOfContents(doc), "-");


public void printBookmarksTree(List<PdfDocument.Bookmark> tree, String sep) {
    for (PdfDocument.Bookmark b : tree) {

        Log.e(TAG, String.format("%s %s, p %d", sep, b.getTitle(), b.getPageIdx()));

        if (b.hasChildren()) {
            printBookmarksTree(b.getChildren(), sep + "-");
View Download
View Direct Download

3. PdfBox-Android

PdfBox-Android is a port of Apache’s PdfBox library to be usable on Android. Most features should in the parent libray are implemented already in PdfBox-Android.

PdfBox-Android requires Android API 19 and greater for full functionality.

PdfBox-Android is yet another library allowing us to render PDF documents. It was written by Tom Roush and has several contributors.

The main code of the PdfBox-Android project is licensed under the Apache 2.0 License, found here.

This library has existed for more than 4 years but still get updated regularly.

Installation of PdfBox-Android

Here’s how to install PdfBox-Android.

Go over to your app level build.gradle and add the the implementation statememt:

dependencies {
    implementation 'com.tom_roush:pdfbox-android:'

You can check the latest version here.

If you are using Maven then:


Before calls to PDFBox are made it is highly recommended to initialize the library’s resource loader. Add the following line before calling PDFBox methods:



Get PdfBox-Android below:

No. Location Link
1. GitHub Direct Download
2. GitHub Browse

Share an Example

Share an Example

What is the capital of Egypt? ( Cairo )