pdf

  
A library to add pdf viewing capabilities inside apps.
Latest Update Stable Release Release Candidate Beta Release Alpha Release
August 7, 2024 - - - 1.0.0-alpha01

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 {
    //TODO: Confirm these dependencies
    implementation "androidx.pdf:pdf:1.0.0-alpha01"
}

Kotlin

dependencies {
    //TODO: Confirm these dependencies
    implementation("androidx.pdf:pdf:1.0.0-alpha01")
}

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