Running without a license key
What NexPDF for Rust 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 a project, write code against it or run it. Until
license::activate succeeds, the SDK runs in view-only mode:
- the
viewermodule works: open, render, extract text, search and read document information; - pages rendered with
render_page_pngcarry a "NexPDF • Unlicensed" watermark; - every call that needs another module returns
Err(Error::Engine(..)).
use nexpdf_sdk::{license, Document};
fn main() -> nexpdf_sdk::Result<()> {
let mut doc = Document::open("contract.pdf")?; // no license::activate call
println!("{}", license::status_json()?); // "state":"unlicensed"
let png = doc.render_page_png(0, 144.0)?; // works, with the watermark
let text = doc.extract_page_text(0)?; // works
if let Err(e) = doc.rotate_page(0, 90) { // needs the editor module
println!("{e}"); // nexpdf: no license activated: 'editor' requires a NexPDF license key
}
println!("{} bytes of PNG, {} characters", png.len(), text.len());
Ok(())
}What works without a key
| Area | Functions |
|---|---|
| Opening and saving | Document::open, Document::from_bytes, Document::open_with_password, Document::from_bytes_with_password, Document::open_image, save, save_bytes, save_linearized, save_linearized_to, try_clone, insert_image_pages |
| Rendering | render_page_png, render_thumb_png, page_width, page_height, page_view_json, set_overprint (render_page_png output is watermarked) |
| Text | extract_page_text, extract_markdown, page_blocks_json, search_json, ask_document |
| Reading structure | metadata_json, outlines_json, page_labels_json, layers_json, set_layer_visible, attachments_json, attachment_data |
| Reading annotations | annotations_json, measurements_json |
| Security | security_json |
| Comparing and memory | compare_json, compare_overlay_png, compare_text_json, compare_annotate, trim_memory, memory_usage_bytes |
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 function.
Check the mode at run time
let status = nexpdf_sdk::license_status_json_value()?; // `serde` feature
match status["state"].as_str() {
Some("unlicensed") => println!("view-only mode, pages are watermarked"),
Some("trial") => println!("trial, {} days left", status["days_left"]),
_ => println!("licensed for {}", status["modules"]),
}Use license::is_licensed("redaction") to hide features your key does not unlock instead of
waiting for the error.
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 license::activate returns
Activation::Trial instead of Activation::Commercial. 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.