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.
NexPDF for Flutter (nexpdf_flutter) has three parts:
NexPdfReaderpresents the complete native reader of the iOS and Android SDKs from Dart: annotations, forms, content editing, redaction, signatures, OCR and more. See Reader.NexPdfViewerWidgetis a lighter, pure-Flutter viewer that renders pages overdart:ffi, on mobile and desktop.NexPdfFlutterandNexPdfDocumentare the Dart API overdart: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
| Dart | 3.3 or later |
| Flutter | 3.19 or later |
Native reader (NexPdfReader) | iOS 15 or later, Android API 24 or later |
dart:ffi API and NexPdfViewerWidget | iOS, Android, macOS, Windows and Linux |
| Dependencies | ffi |
How it works
NexPdfFlutter()loads the engine: linked into the app on iOS,libnexpdf_ffi.soon Android and Linux,libnexpdf_ffi.dylibon macOS andnexpdf_ffi.dllon Windows. Pass aDynamicLibraryto load it from somewhere else.NexPdfDocumentwraps a native handle. Calldispose()when done; a finalizer frees it otherwise. Calls afterdispose()throwStateError.- Failures throw
NexPdfExceptionwith the engine's message inmessage. - 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.handlewithdart:ffi, as each guide shows. See Calling the C API; sdk.invoke(name, args)calls any C function by name throughnexpdf_invoke, for examplesdk.invoke('to_xlsx', [h]). Its documents are integer invoke handles from calls such assdk.invoke('open_bytes', [bytes]), notNexPdfDocumentobjects; free them withsdk.invoke('close', [h]). Byte results come back as base64 strings and JSON results as text.
Getting started
Installation
pubspec, iOS pods, the Android repository and desktop libraries.
Your first document
Open a PDF, render a page and search it.
Add your license key
Activate your key and read the license status.
Running without a key
View-only mode, the watermark and trial keys.
Reader
The native reader and the Flutter viewer widget.
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.