pdfrx 1.1.11 copy "pdfrx: ^1.1.11" to clipboard
pdfrx: ^1.1.11 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 #

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.

Interactive Demo #

A demo site using Flutter Web

pdfrx

Multi-platform support #

  • Android
  • iOS
  • Windows
  • macOS
  • Linux (even on Raspberry PI)
  • Web (*using PDF.js) or Pdfium WASM (*experimental)

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'),
      ),
    );
  }
}
copied to clipboard

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: ^1.1.11
copied to clipboard

Note for Windows #

Ensure your Windows installation enables Developer Mode.

The build process internally uses symbolic links and it requires Developer Mode to be enabled. Without this, you may encounter errors like this.

"Bleeding Edge" Pdfium WASM support on Web #

pdfrx now supports "bleeding edge" Pdfium WASM support on Web. This is still not production-ready, but you can try it by adding additional pdfrx_wasm to your dependencies:

dependencies:
  pdfrx: ^1.1.11
  pdfrx_wasm: ^1.1.6
copied to clipboard

And then, enable Pdfium WASM by adding the following line to somewhere that runs before calling any pdfrx functions (typically main function):

Pdfrx.webRuntimeType = PdfrxWebRuntimeType.pdfiumWasm;
copied to clipboard

The plugin, pdfrx_wasm, is a satellite plugin for pdfrx that contains files required to run Pdfium WASM. Because the WASM binary/support files are relatively large (about 4MB), it is not included in the main pdfrx package and you need to add pdfrx_wasm to your dependencies.

Open PDF File #

PdfViewer supports following functions to open PDF file on specific medium:

Deal with Password Protected PDF Files #

PdfViewer.asset(
  'assets/test.pdf',
  // Most easiest way to return some password
  passwordProvider: () => 'password',

  ...
),
copied to clipboard

For more customization and considerations, see Deal with Password Protected PDF Files using PasswordProvider.

Customizations/Features #

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

Text Selection #

The following fragment enables text selection feature:

PdfViewer.asset(
  'assets/test.pdf',
  params: PdfViewerParams(
    enableTextSelection: true,
    ...
  ),
  ...
),
copied to clipboard

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}',
            ),
          ],
        ),
      );
    },
  ),
),
copied to clipboard

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.

Low Level PDF API #

178
likes
140
points
106k
downloads

Publisher

verified publisherespresso3389.jp

Weekly Downloads

2024.08.10 - 2025.02.22

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.

Repository (GitHub)

Documentation

API reference

License

MIT (license)

Dependencies

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

More

Packages that depend on pdfrx