pdf

  
A library to add pdf viewing capabilities inside apps.
Latest Update Stable Release Release Candidate Beta Release Alpha Release
December 11, 2024 - - - 1.0.0-alpha05

Declaring dependencies

To add a dependency on pdf, you must add the Google Maven repository to your project. Read Google's Maven repository for more information.

Add the dependencies for the artifacts you need in the build.gradle file for your app or module:

Groovy

dependencies {
    implementation "androidx.pdf:pdf-viewer-fragment:1.0.0-alpha05"
}

Kotlin

dependencies {
    implementation("androidx.pdf:pdf-viewer-fragment:1.0.0-alpha05")
}

For more information about dependencies, see Add build dependencies.

Feedback

Your feedback helps make Jetpack better. Let us know if you discover new issues or have ideas for improving this library. Please take a look at the existing issues in this library before you create a new one. You can add your vote to an existing issue by clicking the star button.

Create a new issue

See the Issue Tracker documentation for more information.

There are no release notes for this artifact.

Version 1.0

Version 1.0.0-alpha05

December 11, 2024

androidx.pdf:pdf-document-service:1.0.0-alpha05, androidx.pdf:pdf-viewer:1.0.0-alpha05, and androidx.pdf:pdf-viewer-fragment:1.0.0-alpha05 are released. Version 1.0.0-alpha05 contains these commits.

Bug Fixes

  • This library now uses JSpecify nullness annotations, which are type-use. Kotlin developers should use the following compiler arguments to enforce correct usage: -Xjspecify-annotations=strict, -Xtype-enhancement-improvements-strict-mode (I38301, b/326456246)
  • Fixed previously opened page being displayed after rotation in Android 13. (Ib03dd)
  • Fixed Toolbox disappearing on Rotation. (01148f)

Version 1.0.0-alpha04

November 13, 2024

androidx.pdf:pdf-viewer:1.0.0-alpha04 and androidx.pdf:pdf-viewer-fragment:1.0.0-alpha04 are released. Version 1.0.0-alpha04 contains these commits.

Expanded Compatibility

  • The PDFViewer library now supports Android versions S, T, U, and V. This enhanced compatibility is linked to the SDK extension 13 update.

API Changes

  • Added minimum SdkExtension constraint to PdfViewerFragment. (I922af)
  • Exposing new apis for PDF Viewer library. (I0af57)

Bug Fixes

  • Crash fix for process death issue.
  • UI fixes related to the password dialog.
  • Accessibility fixes for findInFileView and FastscrollView.

Ongoing Development

  • We are actively working on incorporating Jetpack Compose into the library.

Version 1.0.0-alpha03

September 18, 2024

androidx.pdf:pdf-viewer:1.0.0-alpha03 and androidx.pdf:pdf-viewer-fragment:1.0.0-alpha03 are released. Version 1.0.0-alpha03 contains these commits.

Bug Fixes

  • Keyboard not coming up when search is opened for the first time is resolved
  • UI fixes related to the font of FindInFile view.
  • UI fixes for text selection and drag handle.

Known Issues

  • 3D images in PDF documents are not rendered in the viewer.
  • PdfViewerFragment has some performance issues on very large PDF documents (> 250 MB)

Version 1.0.0-alpha02

September 4, 2024

androidx.pdf:pdf-viewer:1.0.0-alpha02 and androidx.pdf:pdf-viewer-fragment:1.0.0-alpha02 are released. Version 1.0.0-alpha02 contains these commits.

Bug Fixes

  • The blurry PDF image issue when rotating from portrait to landscape and the app going to sleep has been resolved.
  • The find in file menu now maintains the result count even when the configuration changes.
  • The FloatingActionButton icon is now available for single-page PDFs.
  • Overlapping issues between the Find in file bar and the FloatingActionButton have been fixed.
  • Text and highlight annotations can now be rendered in the viewer.
  • Accessibility improvements have been made to the Find in file bar.
  • UI fixes have been implemented for rotation, including preserving the find count, addressing the disappearing text selection menu, and resolving the FAB overlapping issue.
  • The find in file menu hiding behind the keyboard in landscape mode has been fixed.

Known Issues

  • 3D images in PDF documents are not rendered in the viewer.
  • PdfViewerFragment has some performance issues on very large PDF documents (> 250 MB)

Version 1.0.0-alpha01

August 7, 2024

androidx.pdf:pdf-viewer:1.0.0-alpha01 and androidx.pdf:pdf-viewer-fragment:1.0.0-alpha01 are released. Version 1.0.0-alpha01 contains these commits.

New Features

The initial alpha release of PDFViewer includes early preview implementations that enable core PDF reading scenarios. Please note that the PdfViewerFragment is currently supported only on Android V (SDK 35) versions. Support for older Android versions will be added in upcoming releases.

  • Introduced PdfViewerFragment which your app can use to render a PDF document. PdfViewerFragment simplifies integrating a PDF viewer in your Activity and lets the users interact in the following ways:
    • Zooming: Pinch in and out to adjust zoom levels for a comfortable reading experience as well as double tap for a quick zoom in/out to the default state.
    • Navigation: Scroll in the default/zoomed state. PdfViewerFragment provides a quick scrubber for fast scrolling between pages.
    • Text actions: Long tapping on text selects it, allowing users to use options like Copy and Select all on the current page.
    • Password-protected documents: PdfViewerFragment provides a dialog box for the user to enter the password and open the document.
    • Navigable hyperlinks: Users can navigate to Web URLs or bookmarks by tapping on hyperlinks within the PDF.
    • Shortcut to annotations mode: Edit mode is not yet supported in PdfViewerFragment. Instead, PdfViewerFragment displays a FloatingActionButton that fires an implicit android.intent.action.ANNOTATE intent with the document URI.

API Changes

  • Added PdfViewerFragment.documentUri property to set a file or content URI for the document and initiate the document loading. PdfViewerFragment displays a loading spinner when the URI is set indicating the background processing of the document.
  • Added PdfViewerFragment.isTextSearchActive to toggle the visibility of the find in file menu. PdfViewerFragment handles the entire flow - allowing input, displaying total number of matches, enabling navigation between results and exiting it.
  • Added onDocumentLoadSuccess and onDocumentLoadError callbacks which are invoked after successful rendering of the document or after an error is thrown before the rendering.

Known Issues

  • Find in file bar overlaps with the FloatingActionButton in some cases.
  • FloatingActionButton icon isn’t visible for single page PDFs.
  • Result count is not preserved on configuration change in the find in file menu.
  • Flickering is observed while closing the find in file menu
  • 3D images in PDF documents are not rendered in the viewer.
  • Accessibility features will be enabled in the following releases.
  • PDF image gets blurry on rotating from portrait to landscape.
  • No support for text/highlight annotation.
  • PdfViewerFragment has some performance issues on very large PDF documents (> 250 MB)

Note