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'},
),
Libraries
- pdf_viewer_pro
- PDF Viewer Pro - A full-featured PDF viewer for Flutter