Skip to content

Android view for displaying PDFs rendered with PdfiumAndroid

License

Notifications You must be signed in to change notification settings

PagoApp/AndroidPdfViewer

 
 

Repository files navigation

Looking for new maintainer!

Android PdfViewer

AndroidPdfViewer 1.x is available on AndroidPdfViewerV1 repo, where can be developed independently. Version 1.x uses different engine for drawing document on canvas, so if you don't like 2.x version, try 1.x.

Library for displaying PDF documents on Android, with animations, gestures, zoom and double tap support. It is based on PdfiumAndroid for decoding PDF files. Works on API 11 (Android 3.0) and higher. Licensed under Apache License 2.0.

What's new in 3.2.0-beta.1?

  • Merge PR #714 with optimized page load
  • Merge PR #776 with fix for max & min zoom level
  • Merge PR #722 with fix for showing right position when view size changed
  • Merge PR #703 with fix for too many threads
  • Merge PR #702 with fix for memory leak
  • Merge PR #689 with possibility to disable long click
  • Merge PR #628 with fix for hiding scroll handle
  • Merge PR #627 with fitEachPage option
  • Merge PR #638 and #406 with fixed NPE
  • Merge PR #780 with README fix
  • Update compile SDK and support library to 28
  • Update Gradle and Gradle Plugin

Changes in 3.0 API

  • Replaced Contants.PRELOAD_COUNT with PRELOAD_OFFSET
  • Removed PDFView#fitToWidth() (variant without arguments)
  • Removed Configurator#invalidPageColor(int) method as invalid pages are not rendered
  • Removed page size parameters from OnRenderListener#onInitiallyRendered(int) method, as document may have different page sizes
  • Removed PDFView#setSwipeVertical() method

Installation

Add to build.gradle:

implementation 'com.github.barteksc:android-pdf-viewer:3.2.0-beta.1'

or if you want to use more stable version:

implementation 'com.github.barteksc:android-pdf-viewer:2.8.2'

Library is available in jcenter repository, probably it'll be in Maven Central soon.

ProGuard

If you are using ProGuard, add following rule to proguard config file:

-keep class com.shockwave.**

Include PDFView in your layout

<com.github.barteksc.pdfviewer.PDFView
        android:id="@+id/pdfView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

Load a PDF file

All available options with default values: