pdf_viewer_pro 0.0.2
pdf_viewer_pro: ^0.0.2 copied to clipboard
A full-featured Flutter PDF viewer for Android and iOS. Built on PDFium (pdfrx). Includes annotations, bookmarks, full-text search, thumbnails, table of contents, auto-scroll, dark/light themes, DRM s [...]
pdf_viewer_pro #
A full-featured PDF viewer for Flutter (Android & iOS) with annotations, bookmarks, DRM protection, search, thumbnails, auto-scroll, and dark/light theme support. Built on PDFium via pdfrx.
Platform Support #
| Android | iOS |
|---|---|
| β | β |
Features #
- π High-performance PDF rendering using PDFium FFI (pdfrx)
- π Bookmarks β add, remove, navigate, sync with server
- βοΈ Annotations β pen drawing, highlighter, notes, eraser with undo/redo
- π€ Text Selection β select and copy PDF text
- π Search β full-text search with match highlighting
- πΌοΈ Thumbnails β page thumbnail grid drawer
- π Table of Contents β hierarchical PDF outline navigation
- π Dark/Light theme support
- βοΈ Scroll direction β toggle vertical/horizontal scroll
- β© Auto-scroll with configurable interval
- π Page slider β bottom navigation bar with page preview
- π DRM protection β screenshot/screen-recording prevention
- βοΈ Keep screen on while reading
- π Session tracking β reading duration and page progress
- π Authenticated downloads via custom HTTP headers
- βοΈ Server sync via callbacks (bookmarks, annotations, sessions)
- πΎ Custom storage β pluggable storage backend
- π€ Share β share PDF or content
- πͺΆ SimplePdfViewer β lightweight view-only widget for invoices/docs
Getting Started #
dependencies:
pdf_viewer_pro: ^0.0.2
Basic Usage #
import 'package:pdf_viewer_pro/pdf_viewer_pro.dart';
// Open from file path
Navigator.push(context, MaterialPageRoute(
builder: (_) => PdfViewerScreen(
filePath: '/path/to/document.pdf',
title: 'My Document',
),
));
// Open from URL
Navigator.push(context, MaterialPageRoute(
builder: (_) => PdfViewerScreen(
fileUrl: 'https://example.com/document.pdf',
title: 'My Document',
),
));
Feature Configuration #
PdfViewerScreen(
filePath: '/path/to/document.pdf',
title: 'My Document',
bookId: 42, // For bookmarks/annotations persistence
featureConfig: PdfViewerFeatureConfig(
enableBookmarks: true,
enableAnnotations: true,
enableSearch: true,
enableTextSelection: true,
enableThumbnails: true,
enableTableOfContents: true,
enableAutoScroll: true,
enableDarkModeToggle: true,
enableFullscreen: true,
enablePageSlider: true,
enableScreenProtection: false,
enableKeepScreenOn: true,
enableSessionTracking: true,
enableScrollDirectionToggle: true,
enableSettings: true,
enableShare: true,
),
);
Built-in Presets #
// All features enabled
featureConfig: PdfViewerFeatureConfig.fullFeatures
// View-only (no annotations/bookmarks)
featureConfig: PdfViewerFeatureConfig.readOnly
// Bare minimum (page slider only)
featureConfig: PdfViewerFeatureConfig.minimal
Simple View-Only Widget #
For invoices, receipts, and documents that only need viewing:
// From file path
SimplePdfViewer.file('/path/to/invoice.pdf')
// From bytes
SimplePdfViewer.data(pdfBytes, sourceName: 'invoice.pdf')
// From URL
SimplePdfViewer.uri(Uri.parse('https://example.com/doc.pdf'))
Theme Customization #
themeConfig: PdfViewerThemeConfig(
primaryColor: Colors.blue,
lightBackgroundColor: Colors.white,
darkBackgroundColor: Color(0xFF121212),
cardBorderRadius: 12.0,
),
Server Sync #
serviceConfig: PdfViewerServiceConfig(
// Sync bookmarks with your server
onBookmarksSync: (bookId, bookmarks) async {
await myApi.saveBookmarks(bookId, bookmarks);
},
onBookmarksLoad: (bookId) async {
return await myApi.loadBookmarks(bookId);
},
// Track reading sessions
onSessionStart: (bookId) async {
await myApi.startSession(bookId);
},
onSessionEnd: (bookId, durationSeconds, currentPage, totalPages) async {
await myApi.endSession(bookId, durationSeconds);
},
// Authenticated file access
httpHeaders: {'Authorization': 'Bearer $token'},
),