Skip to Content
NexPDF

License

Activate a NexPDF license key in a .NET MAUI app, check which modules it unlocks, and handle license errors.

English

Activate the license once per process, before the first document opens. The key must be issued for the device's platform and for your app id (the bundle id on iOS and Mac Catalyst, the package name on Android). See Licensing for how keys are issued and bound.

NexPdfEngine.Platform gives the platform id to use on the current device:

DeviceNexPdfEngine.Platform
iOS, Mac Catalystios
Androidandroid
Windowswindows

Fixed in 1.0.1

In 1.0.0, NexPdfEngine.Activate(license, appId) returned true only for a trial key: a commercial key activated correctly, but Activate treated the engine's result 2 as a failure, returned false and set NexPdfEngine.LastError. From 1.0.1 it returns true for both. On 1.0.0, call NexPdfSdk.ActivateLicense(key, NexPdfEngine.Platform, appId) instead, as below.

Activate

using Nexdevit.NexPdf;
using Nexdevit.NexPdf.Maui;

try
{
    var result = NexPdfSdk.ActivateLicense(licenseXml, NexPdfEngine.Platform, AppInfo.PackageName);
    System.Diagnostics.Debug.WriteLine(result == 1 ? "trial" : "licensed");
}
catch (NexPdfException e)
{
    System.Diagnostics.Debug.WriteLine($"NexPDF license rejected ({e.Code}): {e.Message}");
}

NexPdfSdk.ActivateLicense accepts the license XML or the bare NEX2. key, returns 2 for a commercial key and 1 for a trial key, and throws NexPdfException with a negative Code when it rejects the key.

Check the status

using System.Text.Json.Nodes;

var status = JsonNode.Parse(NexPdfSdk.LicenseStatusJson())!;
var licensed = status["state"]!.GetValue<string>() == "licensed";

if (NexPdfSdk.IsLicensed("annotations"))
    System.Diagnostics.Debug.WriteLine("annotations are available");

LicenseStatusJson() returns state (unlicensed, trial, licensed), licensee, id, tier, modules, expires_at, days_left and watermark.

Error codes

CodeMeaning
-1Malformed key
-2Bad signature
-3Unsupported key version
-4Expired
-5Not yet valid (check the clock)
-6Wrong platform
-7Wrong application id

A call that needs a module your key does not include throws NexPdfException with a message that names the module.

Without a license, or after a rejected key, the SDK stays in viewer mode: PdfView opens and shows documents, text extraction and search work, and rendered pages carry the "NexPDF • Unlicensed" watermark.

On this page