pdfrx_engine 0.2.4 
pdfrx_engine: ^0.2.4 copied to clipboard
pdfrx_engine is a PDF rendering API built on top of PDFium, designed to be used with the pdfrx plugin.
pdfrx_engine #
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 #
- Easy to use PDF APIs
- PdfDocument - Main document interface
- PdfDocument.openFile - Open PDF from file path
 - PdfDocument.openData - Open PDF from memory (Uint8List)
 - PdfDocument.openUri - Open PDF from stream (advanced use case)
 - PdfDocument.openAsset - Open PDF from Flutter asset
 
 - PdfPage - Page representation and rendering
- PdfPage.render - Render page to bitmap
 - PdfPage.loadText - Extract text content from page
 - PdfPage.loadLinks - Extract links from page
 
 
 - PdfDocument - Main document interface
 - PDFium bindings
- For advanced use cases, you can access the raw PDFium bindings via 
package:pdfrx_engine/src/native/pdfium_bindings.dart - Note: Direct use of PDFium bindings is not recommended for most use cases
 
 - For advanced use cases, you can access the raw PDFium bindings via 
 
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