pdf_viewer_pro

pub.dev License: MIT Platform Publisher

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