flutter_plugin_pdf_viewer 1.0.7

  • Readme
  • Changelog
  • Example
  • Installing
  • 93

flutter_plugin_pdf_viewer #

A flutter plugin for handling PDF files. Works on both Android & iOS

Installation #

Add flutter_plugin_pdf_viewer as a dependency in your pubspec.yaml file.

flutter_plugin_pdf_viewer: any

Android #

No permissions required. Uses application cache directory.

iOS #

No permissions required.

How-to: #

Load PDF #

// Load from assets
PDFDocument doc = await PDFDocument.fromAsset('assets/test.pdf');
 
// Load from URL
PDFDocument doc = await PDFDocument.fromURL('http://www.africau.edu/images/default/sample.pdf');

// Load from file
File file  = File('...');
PDFDocument doc = await PDFDocument.fromFile(file);

Load pages #

// Load specific page
PDFPage pageOne = await doc.get(page: _number);

Pre-built viewer #

Use the pre-built PDF Viewer

@override
  Widget build(BuildContext context) {
    Scaffold(
        appBar: AppBar(
          title: Text('Example'),
        ),
        body: Center(
        child: _isLoading
            ? Center(child: CircularProgressIndicator())
            : PDFViewer(document: document)),
    );
  }

This code produces the following view:

Demo Screenshot 1

TODO #

  • Allow password-protected files
  • Refactor PDFDocument.getAll() method
  • Increase page resolution
  • Add swipe to change page

Third-party packages used #

NameDescription
path_providerA Flutter plugin for finding commonly used locations on the filesystem. Supports iOS and Android.
flutter_cache_managerA CacheManager to download and cache files in the cache directory of the app. Various settings on how long to keep a file can be changed.
numberpickerNumberPicker is a custom widget designed for choosing an integer or decimal number by scrolling spinners.
flutter_advanced_networkimageAn advanced image provider provides caching and retrying for flutter app. Now with zoomable widget and transition to image widget.

1.0.7 #

  • Updated project to meet changed requirements by Flutter
  • Updated third-party dependencies
  • Fixes issue #21, #23

1.0.6 #

  • Fixed issue in 1.0.5 on iOS that caused xcode build to fail

1.0.5 #

  • Fixed bug in iOS where due to caching of Flutter ImageProvider when switching documents old pages would persist
  • Added more cases in example demo

1.0.4 #

  • Refactored PDFdocument.getAllPages() method (Thanks for @SergioBernal8 for PR )
  • Added white background to page (iOS)
  • Changed page resolution in iOS to 300 dpi
  • Moved tooltips to a proper class

1.0.3 #

  • Added white background to page (Android)
  • Fixed cocoapods name
  • User can now define tooltips and page selection dialog strings
  • Tapping on page indicator now prompts to user to page selection dialog
  • Added zoom to PDFPage

1.0.2 #

  • Bottom appbar no longer appears if PDF has only one page (Thanks for @markathomas for suggesting this )
  • Fixed opening PDF from assets not working.
  • Example now opens file from assets

1.0.1 #

  • Updated readme.md and added screenshots to package

1.0.0 #

  • Initial release

example/README.md

flutter_pdf_viewer_example #

Demonstrates how to use the flutter_pdf_viewer plugin.

Getting Started #

This project is a starting point for a Flutter application.

A few resources to get you started if this is your first Flutter project:

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  flutter_plugin_pdf_viewer: ^1.0.7

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:flutter_plugin_pdf_viewer/flutter_plugin_pdf_viewer.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
93
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
80
Overall:
Weighted score of the above. [more]
93
Learn more about scoring.

We analyzed this package on Oct 22, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.5.1
  • pana: 0.12.21
  • Flutter: 1.9.1+hotfix.4

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health suggestions

Format lib/src/viewer.dart.

Run flutter format to format lib/src/viewer.dart.

Maintenance issues and suggestions

Support latest dependencies. (-20 points)

The version constraint in pubspec.yaml does not support the latest published versions for 2 dependencies (flutter_advanced_networkimage, rxdart).

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
flutter_advanced_networkimage ^0.5.0 0.5.0 0.6.0-alpha.1
flutter_cache_manager ^1.0.0 1.1.3
numberpicker ^1.0.0 1.1.0
path_provider ^1.1.0 1.4.0
rxdart ^0.21.0 0.21.0 0.22.4
Transitive dependencies
async 2.4.0
charcode 1.1.2
collection 1.14.11 1.14.12
convert 2.1.1
crypto 2.1.3
flutter_svg 0.13.1 0.14.3
http 0.12.0+2
http_parser 3.1.3
infinite_listview 1.0.0
meta 1.1.7
path 1.6.4
path_drawing 0.4.1
path_parsing 0.1.4
pedantic 1.8.0+1
petitparser 2.4.0
platform 2.2.1
sky_engine 0.0.99
source_span 1.5.5
sqflite 1.1.7+1
string_scanner 1.0.5
synchronized 2.1.0+1
term_glyph 1.1.0
typed_data 1.1.6
uuid 2.0.2
vector_math 2.0.8
xml 3.5.0