Skip to Content
NexPDF

Running without a license key

What NexPDF for C and C++ 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 build against NexPDF or run it. Until nexdevit::nexpdf::activate_license (or nexpdf_license_activate in C) succeeds, the SDK runs in view-only mode:

  • the viewer module works: open, render, extract text, search and read document information;
  • pages rendered with render_page_png carry a "NexPDF • Unlicensed" watermark;
  • every call that needs another module throws nexdevit::nexpdf::Error (in C, it fails and sets nexpdf_last_error).
#include <iostream>
#include <nexpdf.hpp>

namespace nexpdf = nexdevit::nexpdf;

int main() {
    auto doc = nexpdf::Document::open("contract.pdf");      // no activate_license call
    std::cout << nexpdf::license_status_json() << "\n";
    // {"state":"unlicensed","modules":["viewer"],"watermark":true}

    write_file("page1.png", doc.render_page_png(0, 144));   // works, with the watermark
    std::cout << doc.extract_page_text(0) << "\n";          // works

    try {
        doc.rotate_page(0, 90);                             // needs the editor module
    } catch (const nexpdf::Error& e) {
        std::cerr << e.what() << "\n";
        // no license activated: 'editor' requires a NexPDF license key
    }
}

write_file is the helper from Getting started.

What works without a key

AreaFunctions and methods
Opening and savingDocument::open, Document::open_bytes, open_bytes_with_password, open_image, save, save_bytes, save_linearized, copy, insert_image_pages
Renderingpage_count, render_page_png, render_thumb_png, page_width, page_height, page_view_json, set_overprint (render_page_png output is watermarked)
Textextract_page_text, extract_markdown, page_blocks_json, search_json, ask_document
Reading structuremetadata_json, outlines_json, page_labels_json, layers_json, set_layer_visible, attachments_json, attachment_data
Reading annotationsannotations_json, measurements_json
Securitysecurity_json
Comparing and memorycompare_json, compare_overlay_png, compare_text_json, compare_annotate, trim_memory, memory_usage_bytes
Libraryversion, license_status_json, is_licensed, has_bundled_fonts, register_standard_font

In C the functions have the same names with the nexpdf_ prefix (nexpdf_render_page_png, nexpdf_open_bytes, ...); open, save, copy and is_licensed are helpers of the C++ layer. Everything else (annotating, filling forms, editing, encrypting, redacting, signing, converting, OCR and PDF/A) needs a key that includes the module. Document::open and open_bytes 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

#include <nlohmann/json.hpp>   // an example; use your JSON library

auto status = nlohmann::json::parse(nexpdf::license_status_json());
if (status["state"] == "unlicensed") {
    std::cout << "view-only mode, pages are watermarked\n";
} else if (status["state"] == "trial") {
    if (!status["days_left"].is_null()) {
        std::cout << "trial, " << status["days_left"] << " days left\n";
    }
} else {
    std::cout << "licensed for " << status["modules"].dump() << "\n";
}

Use nexpdf::is_licensed("redaction") to hide features your key does not unlock instead of waiting for the exception. In C, parse the string from nexpdf_license_status_json() and free it with nexpdf_free_string.

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 activate_license 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.

On this page