Skip to Content
NexPDF

NexPDF for Flutter

Render, search and read PDFs from Dart over dart:ffi, show the native NexPDF reader on iOS and Android, and reach every engine function with NexPDF for Flutter.

English

NexPDF for Flutter (nexpdf_flutter) has three parts:

  • NexPdfReader presents the complete native reader of the iOS and Android SDKs from Dart: annotations, forms, content editing, redaction, signatures, OCR and more. See Reader.
  • NexPdfViewerWidget is a lighter, pure-Flutter viewer that renders pages over dart:ffi, on mobile and desktop.
  • NexPdfFlutter and NexPdfDocument are the Dart API over dart:ffi: open, render, page geometry, search, Markdown, the offline assistant and save, plus the 1.1 features: templates, structured extraction, barcodes, XFA, comment threads, sync, word-level comparison, document timestamps, neural OCR models and PDF/A and PDF/UA validation.

Both readers take the shared UI configuration (NexPdfUIConfig), the same JSON as on the web, iOS, Android and React Native.

import 'package:nexpdf_flutter/nexpdf_flutter.dart';

final sdk = NexPdfFlutter();
final doc = await sdk.openFile(path);
print('${doc.pageCount} pages, first ${doc.pageSize(0)}');
final png = doc.renderPagePng(0, dpi: 144);
final hits = doc.search('invoice');
doc.dispose();

Requirements

Dart3.3 or later
Flutter3.19 or later
Native reader (NexPdfReader)iOS 15 or later, Android API 24 or later
dart:ffi API and NexPdfViewerWidgetiOS, Android, macOS, Windows and Linux
Dependenciesffi

How it works

  • NexPdfFlutter() loads the engine: linked into the app on iOS, libnexpdf_ffi.so on Android and Linux, libnexpdf_ffi.dylib on macOS and nexpdf_ffi.dll on Windows. Pass a DynamicLibrary to load it from somewhere else.
  • NexPdfDocument wraps a native handle. Call dispose() when done; a finalizer frees it otherwise. Calls after dispose() throw StateError.
  • Failures throw NexPdfException with the engine's message in message.
  • Page indices start at 0. Coordinates are PDF points with the origin at the bottom-left of the page (llx, lly, urx, ury).
  • The Dart API is synchronous. Run heavy calls in an isolate, or open the document in the isolate that uses it.

Everything else

The features added in 1.1 have Dart methods, as their guides show. Older features without a Dart method (forms, annotations, editing, conversion, signing, security, OCR, PDF/A conversion) are available three ways:

  • the user does them in the native reader;
  • your code calls the engine's C functions directly on doc.handle with dart:ffi, as each guide shows. See Calling the C API;
  • sdk.invoke(name, args) calls any C function by name through nexpdf_invoke, for example sdk.invoke('to_xlsx', [h]). Its documents are integer invoke handles from calls such as sdk.invoke('open_bytes', [bytes]), not NexPdfDocument objects; free them with sdk.invoke('close', [h]). Byte results come back as base64 strings and JSON results as text.

Getting started

Guides

Opening and saving

Bytes, files, passwords, pictures, HTML, Office and e-books.

Rendering

Pages and thumbnails to PNG, coordinates.

Document structure

Metadata, bookmarks, page labels, layers, attachments.

Text extraction

Text, Markdown, positioned blocks, passages for LLMs.

Search

Find text and draw its rectangles.

OCR

Make scanned pages searchable, in any script.

Structured extraction

Tables, key-values, schema extraction with your LLM, classification.

Barcodes

Read QR, Data Matrix, PDF417 and linear codes; draw barcodes.

Annotations

In the reader, or from code through the C API.

Forms

Fill, create, calculate and flatten fields.

XFA forms

Run FormCalc and JavaScript, lay out dynamic forms, convert to AcroForm, flatten.

Comment threads

Replies and review states on annotations.

Real-time collaboration

Sync pages, annotations, comments, form values and bookmarks.

Editing

Merge, split, reorder, crop; edit text and images.

Compare and optimise

Diff versions, shrink files, control memory.

Word-level comparison

Inserted, deleted, replaced and moved text; annotated PDF.

Security

Encryption, permissions, watermarks, Bates numbers.

Redaction

Remove content for good by area, text or pattern.

Signatures

PAdES signing and verification.

Long-term signatures

PAdES B-LTA, document and archive timestamps.

Conversion

PDF to Word, Excel, PowerPoint, HTML and back.

Templates

PDFs from Word, HTML and PDF templates and JSON data.

PDF/A, PDF/X and PDF/UA

Archiving, print and accessibility.

PDF/A and PDF/UA validation

PDF/A and PDF/UA-1 and -2 with clause ids; convert to PDF/A or PDF/UA.

Help and reference

On this page