pdfrx_engine

Build Test

pdfrx_engine is a platform-agnostic PDF rendering engine built on top of PDFium. It provides low-level PDF document APIs without any Flutter dependencies, making it suitable for use in pure Dart applications, CLI tools, or server-side processing.

This package is a part of pdfrx Flutter plugin, which adds UI widgets and Flutter-specific features on top of this engine.

Multi-platform support

  • Android
  • iOS
  • Windows
  • macOS
  • Linux (even on Raspberry Pi)
  • Web (WASM) supported only on Flutter by pdfrx

Example Code

The following fragment illustrates how to use the PDF engine to load and render a PDF file:

import 'dart:io';
import 'package:image/image.dart' as img;
import 'package:pdfrx_engine/pdfrx_engine.dart';

void main() async {
  await pdfrxInitialize();

  final document = await PdfDocument.openFile('test.pdf');
  final page = document.pages[0]; // first page
  final pageImage = await page.render(
    width: page.width * 200 / 72,
    height: page.height * 200 / 72,
  );
  final image = pageImage!.createImageNF();
  await File('output.png').writeAsBytes(img.encodePng(image));
  pageImage.dispose();
  document.close();
}

You should call pdfrxInitialize() before using any PDF engine APIs to ensure the native PDFium library is properly loaded. For more information, see pdfrx Initialization

PDF API

When to Use pdfrx_engine vs. pdfrx

Use pdfrx_engine when:

  • Building CLI tools or server applications
  • You need PDF rendering without Flutter UI
  • Creating custom PDF processing pipelines
  • Working in pure Dart environments

Use pdfrx when:

  • Building Flutter applications
  • You need ready-to-use PDF viewer widgets
  • You want features like text selection, search, and zoom controls
  • You prefer high-level APIs with Flutter integration

Libraries

pdfrx_engine