Running without a license key
What NexPDF for PHP 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 install the package, write code against it or run it. Until
NexPdf::activateLicense succeeds in the PHP process, 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
Nexdevit\NexPdf\NexPdfException.
<?php
require __DIR__ . '/vendor/autoload.php';
use Nexdevit\NexPdf\Document;
use Nexdevit\NexPdf\NexPdf;
use Nexdevit\NexPdf\NexPdfException;
$doc = Document::open('contract.pdf'); // no activateLicense call
echo NexPdf::licenseStatus()['state'], "\n"; // "unlicensed"
file_put_contents('page1.png', $doc->renderPagePng(0, 144)); // works, with the watermark
echo $doc->extractPageText(0); // works
try {
$doc->rotatePage(0, 90); // needs the editor module
} catch (NexPdfException $e) {
echo $e->getMessage(); // no license activated: 'editor' requires a NexPDF license key
}What works without a key
| Area | Methods |
|---|---|
| Opening and saving | Document::open, Document::openBytes, NexPdf::openBytesWithPassword, NexPdf::openImage, save, saveBytes, saveLinearized, copy, insertImagePages |
| Rendering | pageCount, 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, NexPdf::licenseStatus, NexPdf::isLicensed, NexPdf::hasBundledFonts, NexPdf::registerStandardFont |
Everything else (annotating, filling forms, editing, encrypting, redacting, signing, converting,
OCR and PDF/A) needs a key that includes the module. Document::open and Document::openBytes
also need the conversion module when the input is a Word, Excel, PowerPoint or e-book file. The
API reference names the module of every method.
Check the mode at run time
$status = NexPdf::licenseStatus();
match ($status['state']) {
'unlicensed' => print("view-only mode, pages are watermarked\n"),
'trial' => printf("trial, %d days left\n", $status['days_left']),
default => printf("licensed for %s\n", implode(', ', $status['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.