native_pdf_view 1.0.0 native_pdf_view: ^1.0.0 copied to clipboard
Flutter Plugin to render PDF files on both Android and iOS devices. Provides a Widget to render the pages using a PageView.
native_pdf_view #
Flutter Plugin to render a PDF file. Supports both Android and iOS.
Getting Started #
In your flutter project add the dependency:
dependencies:
...
native_pdf_view: any
For help getting started with Flutter, view the online documentation.
Usage example #
Import native_pdf_view.dart
import 'package:native_pdf_view/native_pdf_view.dart';
import 'package:photo_view/photo_view.dart';
// Load from asset
Widget pdfViewAsset(String path) {
return NativePDFView(
pdfFile: 'assets/sample.pdf',
isAsset: true,
pageBuilder: (imageFile) => PhotoView(
imageProvider: FileImage(imageFile),
initialScale: .40,
maxScale: 1.75,
minScale: .40,
backgroundDecoration: BoxDecoration(
color: Colors.white,
),
),
);
}
// Load from filesystem
Widget pdfViewFS(String path) {
return NativePDFView(
pdfFile: 'path/to/pdf/in/file/system/on/you/smartphone',
isAsset: false,
pageBuilder: (imageFile) => PhotoView(
imageProvider: FileImage(imageFile),
initialScale: .40,
maxScale: 1.75,
minScale: .40,
backgroundDecoration: BoxDecoration(
color: Colors.white,
),
),
);
}
Rendering PDF files on Android devices #
Use the provided widget PdfRenderer
in order to render a PDF file.
This plugin uses the Android native PdfRenderer to render
the pages of PDF files and provides a widget called PdfRenderer
to display the PDF page you like.