Troubleshooting
Fixes for the most common problems with NexPDF for Flutter - the engine library not loading, iOS pods, Android dependencies, license and watermark issues, fonts, signatures, OCR, jank and memory.
The engine library comes from the NexPDF Android SDK the plugin depends on. Check that:
- Gradle resolved
com.nexdevit:nexpdf-android(the plugin asks for the same version as itself,1.1.0for the 1.1.0 plugin) from the Maven folder you unzipped, or frommavenLocal(); see Installation; - the device's ABI is one of
arm64-v8a,armeabi-v7aandx86_64. A 32-bitx86emulator has no library; use anx86_64or arm64 image. If you setabiFilters, keep the device's ABI in it.
On desktop NexPdfFlutter() loads libnexpdf_ffi.dylib, nexpdf_ffi.dll or libnexpdf_ffi.so
by name, so the library must be where the system looks for it: next to the executable on Windows,
inside the app bundle or on the library path on macOS and Linux. Or pass the full path:
final sdk = NexPdfFlutter(DynamicLibrary.open('/opt/nexpdf/lib/libnexpdf_ffi.so'));On macOS, remove the quarantine attribute from a library you downloaded with a browser
(xattr -d com.apple.quarantine libnexpdf_ffi.dylib). On Linux the release library is built on
Ubuntu 22.04 and needs glibc 2.35 or later; there is no musl build.
On iOS the Dart API finds the engine in the app process (DynamicLibrary.process()), so the engine
must be linked into the app through the NexPdf pod. Check that ios/Podfile has both the
NexPdf and NexPdfUI pods with the path of the nexpdf-swift folder, that
NexPdfCore.xcframework is unzipped into that folder, and run pod install again.
The plugin's podspec depends on NexPdfUI, which is not on the CocoaPods trunk. Add both pods with
their local path to the Runner target in ios/Podfile:
pod 'NexPdf', :path => '../nexpdf-swift'
pod 'NexPdfUI', :path => '../nexpdf-swift'The native reader exists only on iOS and Android. On macOS, Windows and Linux use
NexPdfViewerWidget instead. On a phone, the exception means the plugin was added while the app
was running: stop the app and run it again, since hot reload and hot restart do not register new
plugins.
This was a bug in 1.0.0: activateLicense threw for every result other than 1 (trial), so a
valid commercial key, which returns 2, looked like a failure (the key was activated all the
same). Update to 1.0.1, where activateLicense returns 2 or 1. See the
changelog.
Check the state of the license status (see License):
unlicensed:activateLicensewas never called in this app launch, or it threw. Call it at start-up, before the first render, and log the exception.trial: trial keys always keep the "NexPDF • Trial" watermark.licensed: commercial keys render without a watermark. If you still see one, the image is an old render you cached or stored.
The license is process-wide, so one activation also covers background isolates and the native reader.
The key does not list the platform or the app id you passed. activateLicense uses
NexPdfFlutter.platform (ios, android, macos, windows or linux) unless you pass
platform:; the app id must be the iOS bundle id or the Android package name, character for
character. Android flavours or debug builds with an applicationIdSuffix have a different package
name. You can change both in the dashboard and download a re-signed key.
The device clock is earlier than the key's issue date. Set the date and time to automatic and activate again.
Your plan does not include that module. See Modules and tiers for which
plan unlocks it, and check the license status modules to hide the feature.
The PDF uses a standard font (Helvetica, Times, Courier) without embedding it. The default engine
bundles the Liberation fonts as substitutes. If nexpdf_has_bundled_fonts returns 0, register
them yourself through dart:ffi:
// int32_t nexpdf_register_standard_font(const uint8_t *data, size_t len);
final registerFont = nexpdfLib.lookupFunction<Int32 Function(Pointer<Uint8>, Size),
int Function(Pointer<Uint8>, int)>('nexpdf_register_standard_font');
for (final ttf in [sansBytes, serifBytes, monoBytes]) {
using((a) => nexpdfCall(() => registerFont(toNative(ttf, a), ttf.length)));
}The page is a scanned image with no text layer. Run OCR first; it adds an invisible text layer that extraction and search then read.
Signing returns the complete signed file. Write those bytes unchanged. Calling doc.save()
afterwards rewrites the file and invalidates the signature. See
Signatures.
With "engine": "auto", Tesseract is used only when the tesseract program is installed with data
for every requested language. Phones have no Tesseract, so iOS and Android use the built-in engine,
which needs nothing else and reads Latin-script text, unless you load
neural models.
The built-in engine reads Latin-script text only. Load a detection model and a recognition model
for the script with sdk.ocrLoadModel before running OCR, and pass matching languages.
sdk.ocrModels() lists what is loaded; the report's engine says neural (<name>) when a model
was used. See OCR.
The file is a dynamic XFA form, which most viewers no longer lay out. Convert it with
doc.xfaToAcroform() or doc.xfaFlatten(); see XFA forms.
Scripts in the form (FormCalc, JavaScript) are not run.
The document was converted as far as possible, but some PDF/A rules still fail;
sdk.lastError() lists their clauses. Run doc.validatePdfa(level: ...) to see each failure with
its page and object. See PDF/A and PDF/UA validation.
The Dart API is synchronous: a call blocks the isolate that makes it. Large renders, OCR,
conversion or signing on the UI isolate freeze the app until they return. Run them in a background
isolate; see Platform notes.
NexPdfViewerWidget renders its pages on the UI isolate.
Call dispose() on every document you open. The finalizer frees forgotten documents only when the
garbage collector runs, which is not predictable. Long-lived documents can call
nexpdf_trim_memory; see Compare and optimise.
Still stuck? Check Error handling for the meaning of each error, or the general FAQ.