Running without a license key
What NexPDF for Java does before a key is activated, how the watermark works, and how to evaluate every module with a trial key.
You do not need a key to add NexPDF to your build, write code against it or run it. Until
NexPdf.activateLicense succeeds, the SDK runs in view-only mode:
- the
viewermodule works: open, render, extract text, search and read document information; - pages rendered with
renderPagePngcarry a "NexPDF • Unlicensed" watermark; - every call that needs another module throws
NexPdfException.
import com.nexdevit.nexpdf.NexPdf;
import com.nexdevit.nexpdf.NexPdfDocument;
import com.nexdevit.nexpdf.NexPdfException;
import java.nio.file.Path;
try (NexPdfDocument doc = NexPdfDocument.open(Path.of("contract.pdf"))) { // no activateLicense call
System.out.println(NexPdf.licenseStatusJson()); // {"state":"unlicensed",...}
byte[] png = doc.renderPagePng(0, 144); // works, with the watermark
String text = doc.extractPageText(0); // works
try {
doc.rotatePage(0, 90); // needs the editor module
} catch (NexPdfException e) {
System.out.println(e.getMessage()); // no license activated: 'editor' requires a NexPDF license key
}
}What works without a key
| Area | Methods |
|---|---|
| Opening and saving | NexPdfDocument.open, openBytes, openBytesWithPassword, openImage, save, saveBytes, saveLinearized, copy, insertImagePages |
| Rendering | renderPagePng, renderThumbPng, pageWidth, pageHeight, pageViewJson, setOverprint (renderPagePng output is watermarked) |
| Text | extractPageText, extractMarkdown, pageBlocksJson, searchJson, askDocument |
| Reading structure | metadataJson, outlinesJson, pageLabelsJson, layersJson, setLayerVisible, attachmentsJson, attachmentData |
| Reading annotations | annotationsJson, measurementsJson |
| Security | securityJson |
| Comparing and memory | compareJson, compareOverlayPng, compareTextJson, compareAnnotate, trimMemory, memoryUsageBytes |
| Library | NexPdf.version, licenseStatusJson, isLicensed, hasBundledFonts, registerStandardFont |
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.
Check the mode at run time
licenseStatusJson() returns a JSON string; parse it with the JSON library you already use (Jackson
here):
JsonNode status = new ObjectMapper().readTree(NexPdf.licenseStatusJson());
switch (status.get("state").asText()) {
case "unlicensed" -> System.out.println("view-only mode, pages are watermarked");
case "trial" -> System.out.println("trial, " + status.get("days_left").asInt() + " days left");
default -> System.out.println("licensed for " + status.get("modules"));
}Use NexPdf.isLicensed("redaction") to hide features your key does not unlock instead of waiting
for the exception.
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 activateLicense returns 1 instead of
2. Trial keys last 30 days; ask for one from the pricing page 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. Production apps need a commercial key for the modules they use. See Licensing and the modules per plan.