Android Only!
A native Pdf viewer for flutter, built on AndroidPdfViewer, which is based on PdfiumAndroid
- Night Mode
- Scroll Bar
- Horizontal swipe
- Pinch to zoom
- Download PDF from URL
- Features fast, in-memory native XOR - decryption of files.
- Password protected pdf.
- Download and display PDF from URL without ever touching the disk!
Inline Pdf Viewing is not supported. ( A new activity is opened ). See #1.
A proof of concept for inline pdfs is ready at the inline branch.
To use this plugin, follow the installation instructions.
License: MIT
Put test.pdf
at assets/test.pdf
# pubspec.yaml
flutter:
...
assets:
- assets/test.pdf
// main.dart
import 'package:flutter/material.dart';
import 'package:flutter_pdf_viewer/flutter_pdf_viewer.dart';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
home: new Scaffold(
appBar: new AppBar(
title: const Text('Plugin example app'),
),
body: new Center(
child: RaisedButton(
onPressed: () => FlutterPdfViewer.loadAsset('assets/test.pdf'),
child: Text('OPEN'),
),
),
),
);
}
}
Alternatively,
$ git clone https://github.com/pycampers/flutter_pdf_viewer.git
$ cd flutter_pdf_viewer/example
$ flutter run
import 'package:flutter_pdf_viewer/flutter_pdf_viewer.dart';
/// Load Pdf from file path.
/// (Uses the native file URI parser)
Future<void> FlutterPdfViewer.loadFilePath(
String filePath, {
String password,
bool nightMode,
String xorDecryptKey,
bool swipeHorizontal,
})
/// Load Pdf from raw bytes.
Future<void> FlutterPdfViewer.loadBytes(
Uint8List pdfBytes, {
String password,
bool nightMode,
String xorDecryptKey,
bool swipeHorizontal,
})
/// Load Pdf from Flutter's asset folder
Future<void> FlutterPdfViewer.loadAsset(
String assetPath, {
String password,
bool nightMode,
String xorDecryptKey,
bool swipeHorizontal,
})
// Download from url as a file (cached to disk)
Future<String> FlutterPdfViewer.downloadAsFile(String url, {bool cache: true})
// Download from file as bytes (in-memory)
Future<Uint8List> FlutterPdfViewer.downloadAsBytes(String url)
- AndroidPdfViewer for proving this wonderful, and simple to use library.
- #10348.