flutter pdf viewer

A native Pdf viewer for flutter, built on AndroidPdfViewer.

P.S. Android Only!

Features

  • Night Mode
  • Scroll Bar
  • Horizontal swipe
  • Pinch to zoom
  • Download PDF from URL
  • Show inline Videos in Pdf
  • Immersive mode
  • Page by page analytics

Security

  • Features fast native speed XOR - decryption of files.
  • Password protected pdf.
  • Download and display PDF from URL without ever touching the disk!

Drawbacks

  • Inline Pdf Viewing is not supported. ( A new activity is opened ). See #1.

    A proof of concept for inline PDFs is available at the inline branch.

Install

To use this plugin, follow the installation instructions.

pub package

License: MIT

NOTE: You must add these lines at android/app/build.gradle.

(This is required by ExoPlayer, which is used to play videos).

android {
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

Example

$ git clone https://github.com/pycampers/flutter_pdf_viewer.git
$ cd flutter_pdf_viewer/example
$ flutter run

Preview

Generating 64-bit APKs

The Underlying native library tends to blow up the APK size. So, you can build a separate APK for each CPU architecture.

This will also fix an issue with flutter tooling, where 64-bit ARM devices don't work.

Add the following section in android/app/build.gradle -

android {
    defaultConfig {
        ndk {
            abiFilters "<arch>"
        }
    }
}
  • For 32-bit APK, replace <arch> with armeabi-v7a, and run $ flutter build apk --release as usual.

  • For 64-bit APK, replace <arch> with arm64-v8a, and run $ flutter build apk --release --target-platform=android-arm64.

Now you have 2 Apks, which you will need to publish separately to the Play Store. For that you need to tweak the android:versionCode property to have slightly different values for each build.

The exact "Rules for multiple APKs" can be found here.

Thanks


🐍🏕️

Libraries

flutter_pdf_viewer

Dart

dart:ui
Built-in types and core primitives for a Flutter application. [...]

Core

dart:async
Support for asynchronous programming, with classes such as Future and Stream. [...]
dart:collection
Classes and utilities that supplement the collection support in dart:core. [...]
dart:convert
Encoders and decoders for converting between different data representations, including JSON and UTF-8. [...]
dart:core
Built-in types, collections, and other core functionality for every Dart program. [...]
dart:developer
Interact with developer tools such as the debugger and inspector. [...]
dart:math
Mathematical constants and functions, plus a random number generator. [...]
dart:typed_data
Lists that efficiently handle fixed sized data (for example, unsigned 8 byte integers) and SIMD numeric types. [...]

VM

dart:io
File, socket, HTTP, and other I/O support for non-web applications. [...]
dart:isolate
Concurrent programming using isolates: independent workers that are similar to threads but don't share memory, communicating only via messages. [...]