pdfrx 2.1.3 copy "pdfrx: ^2.1.3" to clipboard
pdfrx: ^2.1.3 copied to clipboard

pdfrx is a rich and fast PDF viewer implementation built on the top of PDFium. The plugin supports Android, iOS, Windows, macOS, Linux, and Web.

pdfrx #

Build Test

pdfrx is a rich and fast PDF viewer plugin for Flutter. It provides ready-to-use widgets for displaying PDF documents in your Flutter applications.

This plugin is built on top of pdfrx_engine, which handles the low-level PDF rendering using PDFium. The separation allows for a clean architecture where:

  • pdfrx (this package) - Provides Flutter widgets, UI components, and platform integration
  • pdfrx_engine - Handles PDF parsing and rendering without Flutter dependencies

The plugin supports Android, iOS, Windows, macOS, Linux, and Web.

Interactive Demo #

A demo site using Flutter Web

pdfrx

Multi-platform support #

  • Android
  • iOS
  • Windows
  • macOS
  • Linux (even on Raspberry Pi)
  • Web (WASM)

Example Code #

The following fragment illustrates the easiest way to show a PDF file in assets:

import 'package:pdfrx/pdfrx.dart';

...

class _MyAppState extends State<MyApp> {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Pdfrx example'),
        ),
        body: PdfViewer.asset('assets/hello.pdf'),
      ),
    );
  }
}

Anyway, please follow the instructions below to install on your environment.

Getting Started #

Installation #

Add this to your package's pubspec.yaml file and execute flutter pub get:

dependencies:
  pdfrx: ^2.1.3

Note: You only need to add pdfrx to your dependencies. The pdfrx_engine package is automatically included as a dependency of pdfrx.

Note for Windows #

REQUIRED: You must enable Developer Mode to build pdfrx on Windows.

The build process uses symbolic links which requires Developer Mode to be enabled. If Developer Mode is not enabled:

  • The build will fail with an error message
  • You will see a link to Microsoft's official instructions
  • You must enable Developer Mode and restart your computer before building

Please follow Microsoft's official guide to enable Developer Mode as the exact steps may vary depending on your Windows version.

Note for Building Release Builds #

Please note that the section is not applicable to Web.

Because the plugin contains WASM binaries as its assets and they increase the size of the app regardless of the platform. This is normally OK for development or debugging but you may want to remove them when building release builds.

To do this, do dart run pdfrx:remove_wasm_modules between flutter pub get and flutter build ... on your app project's root directory:

flutter pub get
dart run pdfrx:remove_wasm_modules
flutter build ...

To restore the WASM binaries, run the following command:

dart run pdfrx:remove_wasm_modules --revert

Customizations/Features #

You can customize the behaviors and the viewer look and feel by configuring PdfViewerParams.

Deal with Password Protected PDF Files #

PdfViewer.asset(
  'assets/test.pdf',
  // The easiest way to supply a password
  passwordProvider: () => createSimplePasswordProvider('password'),

  ...
),

See Deal with Password Protected PDF Files using PasswordProvider for more information.

Text Selection #

The text selection feature is enabled by default, allowing users to select text in the PDF viewer. You can customize the text selection behavior using PdfTextSelectionParams.

The following example shows how to disable text selection in the PDF viewer:

PdfViewer.asset(
  'assets/test.pdf',
  params: PdfViewerParams(
    textSelectionParams: PdfTextSelectionParams(
      enabled: false,
      ...
    ),
  ),
  ...
),

The text selection feature supports various customizations, such as:

For more text selection customization, see Text Selection.

PDF Feature Support #

Viewer Customization #

Additional Customizations #

Additional Widgets #

PdfDocumentViewBuilder/PdfPageView #

PdfPageView is just another PDF widget that shows only one page. It accepts PdfDocument and page number to show a page within the document.

PdfDocumentViewBuilder is used to safely manage PdfDocument inside widget tree and it accepts builder parameter that creates child widgets.

The following fragment is a typical use of these widgets:

PdfDocumentViewBuilder.asset(
  'asset/test.pdf',
  builder: (context, document) => ListView.builder(
    itemCount: document?.pages.length ?? 0,
    itemBuilder: (context, index) {
      return Container(
        margin: const EdgeInsets.all(8),
        height: 240,
        child: Column(
          children: [
            SizedBox(
              height: 220,
              child: PdfPageView(
                document: document,
                pageNumber: index + 1,
                alignment: Alignment.center,
              ),
            ),
            Text(
              '${index + 1}',
            ),
          ],
        ),
      );
    },
  ),
),

PdfDocument Management #

PdfDocumentViewBuilder can accept PdfDocumentRef from PdfViewer to safely share the same PdfDocument instance. For more information, see example/viewer/lib/thumbnails_view.dart.

API Documentation #

Flutter Widgets (pdfrx) #

Low-Level PDF API (pdfrx_engine) #

For advanced use cases requiring direct PDF manipulation without Flutter widgets, see the pdfrx_engine API reference. This includes:

241
likes
160
points
182k
downloads
screenshot

Publisher

verified publisherespresso3389.jp

Weekly Downloads

pdfrx is a rich and fast PDF viewer implementation built on the top of PDFium. The plugin supports Android, iOS, Windows, macOS, Linux, and Web.

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

collection, crypto, dart_pubspec_licenses, ffi, flutter, http, path, path_provider, pdfrx_engine, rxdart, synchronized, url_launcher, vector_math, web

More

Packages that depend on pdfrx