A streamlined, easy-to-implement solution from the Jetpack team
As Android developers, weâve long relied on third-party libraries for rendering PDFs in our apps â often trading off stability, customization, or ease of integration. But thatâs changing. AndroidX PDF Viewer is an emerging native solution that simplifies PDF rendering while aligning seamlessly with Jetpack components and modern Android development practices.
Introduction
A lightweight, native PDF rendering library introduced under the AndroidX namespace. Itâs designed to:
- Work out-of-the-box with minimal setup
- Be part of the Jetpack ecosystem
- Replace most third-party solutions for basic PDF needs
- Offer easy-to-use APIs for simple PDF display tasks
- Fully written in Kotlin
â ïž Why Should You Care?
If youâve ever added PDF viewing to your Android app, you know it usually means pulling in a bulky third-party library â often overkill for simply displaying a file. The AndroidX PDF Viewer offers a lightweight, native alternative.
Hereâs why itâs worth your attention:
- Itâs built by the Jetpack team, so it follows modern Android architecture.
- The integration is dead simple â a few lines of code and youâre done.
- You wonât need any third-party licenses or SDK bloats.
- Itâs ideal for basic use cases, like showing invoices, manuals, or reports.
But itâs not all perfect (yet):
- The library is still in alpha (
1.0.0-alpha09
) and under active development. - Customizations are very limited â no theming, annotations, or advanced interactions.
- It may not be stable enough for production in all scenarios.
In short, if your app just needs to display PDFs without extras, this could be the cleanest, most native way to do it.
âïž Time to Integrate
Integrating AndroidX PDF Viewer is quick and straightforward. Just follow these steps:
Add the Dependency
Since the library is still in alpha, make sure youâre using the latest version from the AndroidX release page:
dependencies { implementation("androidx.pdf:pdf-viewer-fragment:1.0.0-alpha09") }
Note: Since itâs in alpha, APIs may change in future releases.
Add Fragment in Your Layout
In your XML file, add the fragment component like this:
<androidx.fragment.app.FragmentContainerView android:id="@+id/pdf_fragment" android:name="androidx.pdf.viewer.fragment.PdfViewerFragment" android:layout_width="match_parent" android:layout_height="match_parent" tools:ignore="NewApi" />
Select PDF File using Document Picker
First, register the document picker and immediately launch it when needed or you can do as you prefer
private val openDocumentLauncher = registerForActivityResult(ActivityResultContracts.OpenDocument()) { uri: Uri? -> uri?.let { openPdf(it) } } // To trigger the picker (e.g., on a button click) openDocumentLauncher.launch(arrayOf("application/pdf"))
Load a PDF Using PdfViewerFragment
You can load the PDF by setting the document URI on the fragment instance like this:
private fun openPdf(uri: Uri) { val pdfViewerFragment = supportFragmentManager.findFragmentById(R.id.pdf_fragment) as? PdfViewerFragment pdfViewerFragment?.documentUri = uri }
Easy, Right?
You can also enable the Find in File feature by activating text search with the isTextSearchActive
 property, when you need it, like this:
pdfViewerFragment?.isTextSearchActive = true
This allows users to search for text within the PDF document, enhancing the reading experience.

If you want to skip the setup and dive straight into working code, Iâve created a sample project that demonstrates,
Â
Job Offers
đ Final Thoughts
AndroidX PDF Viewer is perfect for apps that need to view PDFs without the overhead of full-featured third-party libraries. Itâs simple, fast, and Android-native â just what many developers have been waiting for.
But keep in mind:
- Itâs early in development âdonât expect advanced features.
- Best suited for read-only use cases (e.g., showing invoices, manuals, forms)
This article was previously published on proandroiddev.com.