Blog Post

Open a PDF in an Android App

Illustration: Open a PDF in an Android App

PDF documents are the de facto standard for archiving, transferring, and presenting documents online. Android developers frequently need to display PDF documents within their applications, so in this article, we’ll look at free and open source libraries for displaying PDFs. We’ll also present PSPDFKit as a commercial alternative.

Android SDK

The Android SDK has had basic support for PDF files since API level 21 (Android 5.0). This API resides in a package,, and it supports basic low-level operations, such as creating PDF files and rendering pages to bitmaps. The Android SDK does not provide a UI for interacting with PDF documents, so you’ll need to write your own UI to handle user interaction if you wish to use it as a basis for a PDF viewer in your app.

The main API entry point is PdfRenderer, which provides an easy way to render single pages into bitmaps:

// Create the page renderer for the PDF document.
val fileDescriptor =, ParcelFileDescriptor.MODE_READ_ONLY)
val pdfRenderer = PdfRenderer(fileDescriptor)

// Open the page.
val page = pdfRenderer.openPage(pageNumber)

// Render the page to the bitmap.
val bitmap = Bitmap.createBitmap(page.width, page.height, Bitmap.Config.ARGB_8888)
page.render(bitmap, null, null, PdfRenderer.Page.RENDER_MODE_FOR_DISPLAY)

// Use the rendered bitmap.

// Close the page when you are done with it.


// Close the `PdfRenderer` when you are done with it.

You can now set these rendered bitmaps into an ImageView or build your own UI that handles multi-page documents, scrolling, and zooming.

Now we are going to introduce libraries that support basic, ready-to-use UIs for displaying documents.


One of the most widely known PDF libraries is MuPDF. It is available either as a commercial solution or under an open source (AGPL) license.

MuPDF provides a small and fast viewer with a basic UI. Embedding it in your app is simple:

repositories {
    maven { url' }

dependencies {
	compile 'com.artifex.mupdf:viewer:1.12.+'

You can now open the MuPDF viewer activity by launching an intent with a document URI:

import com.artifex.mupdf.viewer.DocumentActivity;


val intent = Intent(this,
intent.action = Intent.ACTION_VIEW = Uri.fromFile(documentFile)

Using DocumentActivity is enough for most basic use cases. MuPDF ships with its entire source code, so you can build any required functionality on top of it.

ℹ️ Note: MuPDF also supports other document formats on top of PDF, such as XPS, CBZ, EPUB, and FictionBook 2.

Android PdfViewer

Android PdfViewer is a library for displaying PDF documents. It has basic support for page layouts, zooming, and touch gestures. It is available under the Apache License, Version 2.0 and, as such, is free to use, even in commercial apps.

Integration is simple. Start with adding a library dependency to your build.gradle file:

compile 'com.github.barteksc:android-pdf-viewer:3.1.0-beta.1'

Then add the main PDFView to the layout where you wish to view the PDFs:


Now you can load the document in your activity:

val pdfView = findViewById<PdfView>(

PSPDFKit for Android

The above solutions are free or open source libraries with viewer capabilities. However, the PDF spec is fairly complex and it defines many more features on top of the basic document viewing capabilities. We at PSPDFKit offer a comprehensive PDF solution for Android and other platforms, along with first-class support included with every plan. PSPDFKit comes with a fully featured document viewer with a modern customizable user interface and a range of additional features such as:

  • Annotation editing

  • Interactive forms with JavaScript support

  • Digital signatures

  • Indexed search

  • Document editing (both programmatically and through the UI)

  • Redaction

  • And much more

If you are interested in our solution, click here to learn more and get a trial of PSPDFKit for Android.


In this post, we’ve outlined some of the available PDF viewer libraries for Android. Whether you choose any of the presented free or open source libraries or you want the fully featured commercial solution found in PSPDFKit, integrating PDF capabilities into your apps is relatively easy.

Share Post

Related Articles

Explore more
DEVELOPMENT  |  Android • Development • How To • Flutter

How to Customize Our Flutter PDF SDK

TUTORIALS  |  Android • Development • How To • Kotlin

Converting an Image to PDF in Kotlin

RELEASES  |  Android • Development • Products

PSPDFKit 6.6 for Android