AndroidPDFPreview is a lightweight and easy-to-use library for displaying and interacting with PDFs in your Android applications. Built on top of PdfiumAndroid for decoding and AndroidPdfViewer for rendering, it delivers a smooth and user-friendly experience.
- Display and interact with PDF documents
- Support for gestures, zoom, and double tap
- Lightweight and easy to integrate into your Android apps
- Compatible with Android versions 5.1 and above
To install AndroidPDFPreview, add the following dependency to your project's Gradle file:
dependencies {
implementation 'io.github.rhariskumar3:pdfpreview:1.0.0'
}
-
Add a
PDFView
to your layout:XML
<com.harissk.pdfpreview.PDFView android:id="@+id/pdf_view" android:layout_width="match_parent" android:layout_height="match_parent" />
-
Load a PDF in your code:
Kotlin
binding.pdfView.load(file) { defaultPage(0) swipeHorizontal(true) enableAnnotationRendering(true) spacing(10F) // in dp // Listeners documentLoadListener(...) renderingEventListener(...) pageNavigationEventListener(...) gestureEventListener(...) linkHandler(...) }
Use code with caution. Learn more
- Asset
- File
- Uri
- ByteArray
- InputStream
- DocumentSource (custom)
AndroidPDFPreview supports a number of additional features, including:
- Page navigation
- Search (coming soon)
- Table of contents
- Bookmarks
- Annotations (coming soon)
We welcome contributions! Raise pull requests or file issues on GitHub.
Have questions or feedback? Reach out to us at [https://github.com/rhariskumar3/pdfpreview]
Thanks to these projects:
We hope you find AndroidPDFPreview to be a valuable tool for developing your Android apps.
Copyright 2023 AndroidPDFPreview Contributors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
** Happy coding! **