Skip to content
pubscout

pdfrx_engine

0.9.6, released today by espresso3389.jp

Pure Dart PDF rendering and manipulation API built on top of PDFium.

WASM-ready
$ flutter pub add pdfrx_engine
Source repository

What it does

pdfrx_engine provides low-level PDF document APIs for viewing, editing, combining PDF documents, and importing images without any Flutter dependencies. It relies on PDFium bindings to support rendering pages to bitmaps, extracting text, handling links, and creating or modifying PDF files in pure Dart applications, CLI tools, or server-side environments.

AI-written summary of version 0.9.1, based on the package's README and metadata. Report an inaccuracy

Use it when

  • Building CLI tools or server applications that process PDFs in pure Dart
  • You need PDF rendering and manipulation capabilities without Flutter UI dependencies
  • Creating custom PDF processing pipelines or combining multiple PDF documents

Skip it when

  • You are building a Flutter application and need high-level UI widgets like ready-to-use PDF viewers
  • You prefer an all-in-one Flutter plugin with built-in UI, text selection, and zoom controls (use pdfrx instead)

Strengths

  • Platform-agnostic and works in pure Dart environments without Flutter dependencies
  • Built on top of PDFium for robust PDF rendering and manipulation
  • Supports page combining, image-to-PDF conversion, text extraction, and link loading

Weaknesses

  • Native builds require a C toolchain to compile a small bundled library for thread safety
  • Does not include Flutter UI widgets or high-level viewer controls by itself

Setup

Kind
FFI (native library)
Effort
Medium
Code generation
No
Direct dependencies
12

Requires calling pdfrxInitialize() before using any PDF engine APIs. Native builds also require a C toolchain to compile the bundled library that prevents simultaneous PDFium access.

import 'dart:io';
import 'package:pdfrx_engine/pdfrx_engine.dart';

void main() async {
  await pdfrxInitialize();

  final document = await PdfDocument.openFile('test.pdf');
  try {
    if (document.pages.isEmpty) return;
    final page = document.pages.first;
    final pageImage = await page.render(
      width: (page.width * 200 / 72).round(),
      height: (page.height * 200 / 72).round(),
    );
    if (pageImage == null) return;
    try {
      final image = pageImage.createImageNF();
      await File('output.png').writeAsBytes(img.encodePng(image));
    } finally {
      pageImage.dispose();
    }
  } finally {
    await document.dispose();
  }
}

Alternatives

Packages that do the same job and could replace pdfrx_engine.

Works with

Packages commonly used together with pdfrx_engine: ones it builds on, ones built on it, and its own family.