Skip to Content
NexPDF

Running without a license key

What NexPDF for Android does before a key is activated, how the watermark works, and how to evaluate every module with a trial key.

English

You do not need a key to add the AAR, write code against it or run it. Until NexPdfLicense.initialize returns 1 or 2, the SDK runs in view-only mode:

  • the viewer module works: open, render, extract text, search and read document information;
  • pages rendered with renderPagePng carry a "NexPDF • Unlicensed" watermark;
  • every call that needs another module fails (false, 0, -1 or an empty result), and NexPdfJni.lastError() says why.
import com.nexdevit.nexpdf.NexPdfDocument
import com.nexdevit.nexpdf.NexPdfJni
import com.nexdevit.nexpdf.NexPdfLicense
import org.json.JSONObject

NexPdfDocument.openBytes(bytes).use { doc ->                 // no initialize call
    Log.i("NexPDF", JSONObject(NexPdfLicense.status()).optString("state"))   // "unlicensed"
    val png = doc.renderPagePng(0, 144.0)                     // works, with the watermark
    val text = doc.pageText(0)                                // works

    if (!NexPdfJni.rotatePage(doc.handle(), 0, 90)) {         // needs the editor module
        Log.w("NexPDF", NexPdfJni.lastError())
        // no license activated: 'editor' requires a NexPDF license key
    }
}

What works without a key

AreaMethods
Opening and savingNexPdfDocument.openBytes, NexPdfJni.openBytesWithPassword, saveBytes, insertImagePages
RenderingrenderPagePng, renderThumbPng, pageWidth, pageHeight, pageView, pageViewJson (renderPagePng output is watermarked)
TextpageText / extractPageText, toMarkdown / extractMarkdown, pageBlocksJson, searchJson
Reading structuremetadataJson, outlinesJson, layersJson, setLayerVisible, attachmentsJson, attachmentData
Reading annotationsannotationsJson, measurementsJson
SecuritysecurityJson
Comparing and memorycompareJson, compareOverlayPng, trimMemory, memoryUsageBytes

saveLinearized, setOverprint, pageLabelsJson and askDocument work without a key too, and so do the word-level comparison calls compareTextJson and compareAnnotate.

Everything else (annotating, filling forms, editing, encrypting, redacting, signing, converting, OCR and PDF/A) needs a key that includes the module. The API reference names the module of every method.

The reader works the same way: viewing, search, bookmarks and thumbnails work without a key. When it starts without a key it shows "No NexPDF license: view-only mode", and an editing action that needs a module shows "This feature needs a NexPDF license".

Check the mode at run time

NexPdfLicense.status() returns the license as JSON. A small helper tells you whether a module is unlocked:

fun isLicensed(module: String): Boolean {
    val modules = JSONObject(NexPdfLicense.status()).optJSONArray("modules") ?: return false
    return (0 until modules.length()).any { modules.getString(it) == module }
}

val status = JSONObject(NexPdfLicense.status())
when (status.optString("state")) {
    "unlicensed" -> Log.i("NexPDF", "view-only mode, pages are watermarked")
    "trial" -> Log.i("NexPDF", "trial, ${status.optInt("days_left")} days left")
    else -> Log.i("NexPDF", "licensed for ${status.optJSONArray("modules")}")
}

Use isLicensed("redaction") to hide features your key does not unlock instead of waiting for the error. To limit the reader to what the key unlocks, pass only those modes in modeConfig.availableModes.

Evaluate with a trial key

A trial key unlocks every module so you can try annotations, signing, redaction and the rest. It keeps a "NexPDF • Trial" watermark on rendered pages, and initialize returns NexPdfLicense.TRIAL (1) instead of NexPdfLicense.LICENSED (2). Trial keys last 30 days; ask for one from the pricing page with your package name, and activate it exactly like a commercial key; see License.

Do not ship view-only or trial builds

The watermark is drawn on the pixels of rendered pages only; documents you save are not changed. Even so, view-only and trial modes are for development and evaluation. Play Store builds need a commercial key for the modules they use. See Licensing and the modules per plan.

On this page