Platform notes
UI thread and background work, memory, app size and deployment notes for NexPDF for .NET MAUI on Android, iOS, Mac Catalyst and Windows.
UI thread and background work
- Every engine call is synchronous and blocks the thread that makes it. Rendering a page,
converting, OCR, signing or optimising can take long enough to freeze the UI, so run them with
await Task.Run(...)and update the UI after theawait. PdfViewalready works in the background:LoadAsyncopens the document and reads the page sizes on a worker thread, and pages are rendered on a worker thread and handed to the UI thread.LoadFailedandPageChangedarrive on the UI thread in normal use.
var doc = view.Document!;
var markdown = await Task.Run(() => doc.ToMarkdown()); // off the UI thread
NotesEditor.Text = markdown; // back on the UI threadThreading
- A
NexPdfDocumentis not thread-safe. Use each document from one thread at a time. PdfViewrendersview.Documenton a worker thread with a lock your calls do not take. A call you make onview.Documentwhile the view is rendering can overlap it. For long work, use your ownNexPdfDocumentopened from the same bytes and hand the result toLoadAsync; see PdfView.- Different documents can be used on different threads at the same time. The state shared between documents (the license and the renderer's caches) is thread-safe.
- The license is process-wide: activate it once, in
MauiProgram.CreateMauiApp. - Errors are tracked per thread, so an error on one thread never leaks into another.
Memory
- A document is read fully into memory when it is opened. Budget roughly the file size plus the decoded pages you touch, and check the size of files users pick before loading very large ones on phones.
PdfViewkeeps the PNGs of the pages near the current one and drops the others, so scrolling a long document does not keep every page in memory.- The renderer keeps process-wide caches of parsed fonts, glyphs and decoded images, shared by every document. Each cache is bounded by size and drops its least recently used entries first; together they can hold up to about 1.3 GB in a process that renders many large, image-heavy files. There is no call to make them smaller.
doc.MemoryUsageBytes()estimates what a document uses, anddoc.TrimMemory()compacts its buffers and returns the bytes reclaimed; see Compare and optimise.- Dispose what you no longer need:
PdfView.Dispose()frees the view's document, and everyNexPdfDocumentyou open yourself belongs in ausing.
App size
- Android: a copy of
libnexpdf_ffi.sois added for each ABI found undernative/android/jni/, so each ABI adds a full engine to the APK. Keep only the ABIs you ship (for examplearm64-v8a, plusx86_64for emulators), or publish an Android App Bundle so each device downloads one ABI. - iOS and Mac Catalyst: the engine is linked statically from
NexPdfCore.xcframeworkinto the app binary; there is no separate library file to ship. - Windows:
nexpdf_ffi.dll(x64) is copied next to the app, about 20 MB. - The default engine compiles in the Liberation fonts (about 4 MB) used for non-embedded standard
fonts and PDF/A.
NexPdfSdk.HasBundledFonts()tells you which build you have.
Files on the device
NexPdfDocument.Open(path) and Save(path) read and write real files. Files bundled in
Resources/Raw are not files on Android, so read them as bytes with
FileSystem.OpenAppPackageFileAsync and use OpenBytes or LoadAsync. Write output to
FileSystem.AppDataDirectory or FileSystem.CacheDirectory; see
Opening and saving.
Licensing per platform
NexPdfEngine.Platform is the platform id the key must list on the current device: ios on iOS
and Mac Catalyst, android on Android, windows on Windows. The app id is your bundle id or
package name. See License.
Network
The engine makes no network calls of its own: license keys are verified offline and documents
never leave the device. Only signing options you set (tsa_url for a timestamp, ltv for OCSP
and CRL lookups) and NexPdfSdk.AddLtv contact the servers named in the certificates.