Skip to Content
NexPDF

API reference

Every class, method and function of the NexPDF C++ SDK, grouped by feature. Generated from NexPDF 1.1.0.

English

Generated from NexPDF 1.1.0

This page is generated from the sources of nexpdf.hpp (CMake target nexdevit::nexpdf). It lists 193 members. Options and results that are JSON strings use the same JSON in every NexPDF SDK. Module is the license module a call needs; calls marked "always available" work without a license key.

Setup and lifecycle

open_bytes

static Document open_bytes(const std::vector<uint8_t>& data, const std::optional<std::string>& password = std::nullopt)

Opens a PDF (or a JPEG/PNG/TIFF picture) from bytes; Word, Excel and PowerPoint files, EPUB / FictionBook / XPS books and CBZ comics are converted. A password opens encrypted files.

On Document

open

static Document open(const std::string& path, const std::optional<std::string>& password = std::nullopt)

Reads and opens a file; see open_bytes.

On Document

handle

NexPdfDocument* handle() const noexcept

The C handle, for calls not wrapped here. Still owned by this object.

On Document

save

void save(const std::string& path, bool linearized = false) const

Writes the document; linearized writes a "Fast Web View" file.

On Document

copy

Document copy() const

An independent copy (for undo snapshots or work on another thread).

On Document

reset

void reset() noexcept

Frees the native document now.

On Document

version

inline std::string version()

The engine version.

On namespace nexdevit::nexpdf

activate_license

inline int32_t activate_license(const std::string& key_or_xml, const std::string& platform, const std::string& app_id)

Activates a license key or license.xml once per process: 2 (licensed) or 1 (trial); throws Error with the negative code otherwise. Without a license the SDK is view-only and renders carry a watermark. platform: android, ios, web, windows, macos, linux or server.

On namespace nexdevit::nexpdf

tsa_trampoline

inline int32_t tsa_trampoline(const uint8_t* request, size_t len, void*, const uint8_t** out_token, size_t* out_len) noexcept

The C callback: calls the registered std::function; the answer lives in a per-thread buffer until the next call on that thread (NexPDF copies it when this returns).

On namespace nexdevit::nexpdf

set_tsa_callback

inline void set_tsa_callback(TsaCallback callback)

Registers a process-wide time-stamp authority (an empty function clears it). Used when no "tsa_url" is given by add_document_timestamp(_bytes), and by sign_pkcs12 / complete_external_signature with "level" B-T, B-LT or B-LTA; "tsa_url" always wins. The callback may run on any thread calling NexPDF and must not call set_tsa_callback. If it throws, the NexPDF call fails with "TSA callback failed (code 1)"; an empty answer gives code 2.

On namespace nexdevit::nexpdf

clear_tsa_callback

inline void clear_tsa_callback()

Unregisters the time-stamp authority callback (B-T and later then need "tsa_url" again).

On namespace nexdevit::nexpdf

is_licensed

inline bool is_licensed(const std::string& module)

Whether the active license unlocks module (annotations, forms, editor, security, redaction, signatures, conversion, ocr, standards).

On namespace nexdevit::nexpdf

Library and licensing

license_status_json

inline std::string license_status_json()

The whole API behind one JSON call, for bridges that only pass strings: {"fn":"to_xlsx","args":[handle]} returns {"ok":true,"result":...} or {"ok":false,"error":"..."}. Documents are handle numbers and byte buffers base64.

On namespace nexdevit::nexpdf · always available · C nexpdf_invoke

invoke

inline std::string invoke(const std::optional<std::string>& request_json = std::nullopt)

The whole API behind one JSON call, for bridges that only pass strings: {"fn":"to_xlsx","args":[handle]} returns {"ok":true,"result":...} or {"ok":false,"error":"..."}. Documents are handle numbers and byte buffers base64.

On namespace nexdevit::nexpdf · always available · C nexpdf_invoke

register_standard_font

inline int32_t register_standard_font(const std::vector<uint8_t>& data)

Registers a Helvetica, Times or Courier compatible TrueType font (for example Liberation) used for non-embedded standard fonts and PDF/A. Needed only by builds without bundled fonts. 1 on success, 0 if the font is not such a font.

On namespace nexdevit::nexpdf · always available · C nexpdf_register_standard_font

Opening and saving

open_bytes_with_password

inline Document open_bytes_with_password(const std::vector<uint8_t>& data, const std::optional<std::string>& password = std::nullopt)

Opens an encrypted PDF with its user or owner password (RC4, AES-128, AES-256). Fails with "password required" or "incorrect password" when the password is the problem.

On namespace nexdevit::nexpdf · always available · C nexpdf_open_bytes_with_password

from_html

inline Document from_html(const std::optional<std::string>& html = std::nullopt)

Lays out HTML as a new PDF document.

On namespace nexdevit::nexpdf · module conversion · C nexpdf_from_html

has_bundled_fonts

inline int32_t has_bundled_fonts()

Converts Word, Excel or PowerPoint bytes (format detected) to a new PDF document.

On namespace nexdevit::nexpdf · module conversion · C nexpdf_open_office

open_office

inline Document open_office(const std::vector<uint8_t>& data)

Converts Word, Excel or PowerPoint bytes (format detected) to a new PDF document.

On namespace nexdevit::nexpdf · module conversion · C nexpdf_open_office

open_ebook

inline Document open_ebook(const std::vector<uint8_t>& data)

Converts EPUB, FictionBook (.fb2, .fb2.zip), XPS/OpenXPS or a CBZ comic archive to a new PDF document.

On namespace nexdevit::nexpdf · module conversion · C nexpdf_open_ebook

open_image

inline Document open_image(const std::vector<uint8_t>& data)

Converts JPEG, PNG or TIFF bytes to a new PDF, one page per picture.

On namespace nexdevit::nexpdf · always available · C nexpdf_open_image

save_bytes

std::vector<uint8_t> save_bytes() const

The document, with every change, as PDF bytes (full rewrite).

On Document · always available · C nexpdf_save_bytes

save_linearized

std::vector<uint8_t> save_linearized() const

A linearized ("Fast Web View") PDF: the first page shows before the download ends.

On Document · always available · C nexpdf_save_linearized

Pages and rendering

page_count

int32_t page_count() const

Number of pages.

On Document · always available · C nexpdf_page_count

page_width

double page_width(size_t page_index) const

Displayed page width in points (crop box, rotation and /UserUnit applied).

On Document · always available · C nexpdf_page_width

page_height

double page_height(size_t page_index) const

Displayed page height in points (crop box, rotation and /UserUnit applied).

On Document · always available · C nexpdf_page_height

page_view_json

std::string page_view_json(size_t page_index) const

How the page is displayed: width, height, rotation, user_unit, crop and the PDF-to-display matrix to_display.

On Document · always available · C nexpdf_page_view_json

render_page_png

std::vector<uint8_t> render_page_png(size_t page_index, double dpi) const

Renders a page to PNG at the given resolution (dots per inch). Unlicensed and trial renders carry a watermark.

On Document · always available · C nexpdf_render_page_png

render_thumb_png

std::vector<uint8_t> render_thumb_png(size_t page_index, uint32_t max_dim) const

Renders a thumbnail PNG whose longer side is at most max_dim pixels.

On Document · always available · C nexpdf_render_thumb_png

set_overprint

int32_t set_overprint(int32_t mode)

Overprint simulation for later renders: 0 = PDF/X documents only (default), 1 = always, 2 = never.

On Document · always available · C nexpdf_set_overprint

Text, search and assistant

extract_page_text

std::string extract_page_text(size_t page_index) const

The text of a page in reading order.

On Document · always available · C nexpdf_extract_page_text

extract_markdown

std::string extract_markdown() const

The whole document as Markdown (headings, lists, tables).

On Document · always available · C nexpdf_extract_markdown

search_json

std::string search_json(const std::optional<std::string>& query = std::nullopt) const

Finds a text in every page (case-insensitive). Returns a JSON array of hits: page, context and the rectangle llx, lly, urx, ury in PDF points.

On Document · always available · C nexpdf_search_json

page_blocks_json

std::string page_blocks_json(size_t page_index) const

The text blocks of a page as JSON: text, font size and the rectangle llx, lly, urx, ury.

On Document · always available · C nexpdf_page_blocks_json

ask_document

std::string ask_document(const std::optional<std::string>& question, uint32_t k, uint32_t max_chars) const

Document assistant retrieval, offline (BM25): the k passages most relevant to a question and a page-tagged context of at most max_chars characters (0 = 200000) to send to a language model. Returns {"passages":[{"page","text","score"}],"context":"...","context_pages":[...]}.

On Document · always available · C nexpdf_ask_document

page_words_json

std::string page_words_json(size_t page_index, const std::optional<std::string>& options_json = std::nullopt) const

The words of a page with exact boxes from the glyph widths and the text state: text, bbox, quad (follows rotated text), font, size, angle, line. {"glyphs":true} adds the glyph boxes.

On Document · always available · C nexpdf_page_words_json

Conversion

to_html

std::string to_html() const

The document as HTML.

On Document · module conversion · C nexpdf_to_html

to_json

std::string to_json() const

The document content as JSON.

On Document · module conversion · C nexpdf_to_json

to_xml

std::string to_xml() const

The document content as XML.

On Document · module conversion · C nexpdf_to_xml

to_csv

std::string to_csv() const

Tables of the document as CSV.

On Document · module conversion · C nexpdf_to_csv

to_rtf

std::string to_rtf() const

The document as RTF.

On Document · module conversion · C nexpdf_to_rtf

to_docx

std::vector<uint8_t> to_docx() const

The document as a Word (.docx) file.

On Document · module conversion · C nexpdf_to_docx

to_xlsx

std::vector<uint8_t> to_xlsx() const

The document as an Excel workbook, one sheet per page.

On Document · module conversion · C nexpdf_to_xlsx

to_pptx

std::vector<uint8_t> to_pptx() const

The document as a PowerPoint presentation, one slide per page.

On Document · module conversion · C nexpdf_to_pptx

to_reflow_html

std::string to_reflow_html(const std::optional<std::string>& options_json = std::nullopt) const

The text as responsive HTML for small screens. Options (may be omitted): {"pages":[0],"images":true,"full_page":true,"title":"..."}.

On Document · module conversion · C nexpdf_to_reflow_html

open_xlsx_with_clock

inline Document open_xlsx_with_clock(const std::vector<uint8_t>& data, double clock_unix_seconds)

Converts an Excel workbook with a fixed clock: NOW() and TODAY() in formulas without a cached value return the given Unix time (seconds, no time zone applied).

On namespace nexdevit::nexpdf · module conversion · C nexpdf_open_xlsx_with_clock

open_docx_with_options_json

inline Document open_docx_with_options_json(const std::vector<uint8_t>& data, const std::optional<std::string>& options_json = std::nullopt)

Converts a Word document with options {"show_comments":false,"show_revisions":false}: comments in balloons in a markup area, and tracked changes drawn as markup instead of the final document.

On namespace nexdevit::nexpdf · module conversion · C nexpdf_open_docx_with_options_json

Templates

template_docx_to_pdf

inline Document template_docx_to_pdf(const std::vector<uint8_t>& template_bytes, const std::optional<std::string>& data_json = std::nullopt, const std::optional<std::string>& options_json = std::nullopt)

Fills a Word template with JSON data and converts it to a new PDF document. Options: {"strict":false,"locale":"en"}; with strict a missing field fails the call.

On namespace nexdevit::nexpdf · module conversion · C nexpdf_template_docx_to_pdf

template_docx_fill

inline std::vector<uint8_t> template_docx_fill(const std::vector<uint8_t>& template_bytes, const std::optional<std::string>& data_json = std::nullopt)

Fills a Word template with JSON data and returns the new .docx bytes.

On namespace nexdevit::nexpdf · module conversion · C nexpdf_template_docx_fill

template_html_to_pdf

inline Document template_html_to_pdf(const std::optional<std::string>& html_utf8 = std::nullopt, const std::optional<std::string>& data_json = std::nullopt, const std::optional<std::string>& options_json = std::nullopt)

Fills an HTML template with JSON data (values HTML-escaped, {{{raw}}} not) and lays it out as a new PDF document.

On namespace nexdevit::nexpdf · module conversion · C nexpdf_template_html_to_pdf

template_fill_pdf

int32_t template_fill_pdf(const std::optional<std::string>& data_json = std::nullopt, const std::optional<std::string>& options_json = std::nullopt)

Fills a PDF template in place: AcroForm fields by name and placeholders in the page text. Options {"flatten","fields","text","strict","locale"}. Returns the number of fields and text lines filled.

On Document · module conversion · C nexpdf_template_fill_pdf

template_docx_fill_with

inline std::vector<uint8_t> template_docx_fill_with(const std::vector<uint8_t>& template_bytes, const std::optional<std::string>& data_json = std::nullopt, const std::optional<std::string>& options_json = std::nullopt)

Fills a Word template with JSON data and options {"strict","locale"}, and returns the new .docx bytes.

On namespace nexdevit::nexpdf · module conversion · C nexpdf_template_docx_fill_with

Office editing

xlsx_edit

inline std::vector<uint8_t> xlsx_edit(const std::vector<uint8_t>& data, const std::optional<std::string>& edits_json = std::nullopt)

Sets cells of an Excel workbook (numbers, text, booleans, formulas, or null to clear), recalculates every formula and the charts, and returns the new .xlsx bytes. JSON {"sheet","edits":[{"cell","value"}],"ranges":[{"start","rows"}],"recalculate"}.

On namespace nexdevit::nexpdf · module conversion · C nexpdf_xlsx_edit

xlsx_cells_json

inline std::string xlsx_cells_json(const std::vector<uint8_t>& data, const std::optional<std::string>& options_json = std::nullopt)

The cells of an Excel workbook as JSON: per sheet, each cell with its type, value and formula. Options {"sheet","range","recalculate"}.

On namespace nexdevit::nexpdf · module conversion · C nexpdf_xlsx_cells_json

docx_edit

inline std::vector<uint8_t> docx_edit(const std::vector<uint8_t>& data, const std::optional<std::string>& ops_json = std::nullopt)

Applies operations to a Word document and returns the new .docx bytes: replace (across runs, headers and footers), set_text, insert and delete paragraphs.

On namespace nexdevit::nexpdf · module conversion · C nexpdf_docx_edit

docx_paragraphs_json

inline std::string docx_paragraphs_json(const std::vector<uint8_t>& data)

The paragraphs of a Word document as JSON: index, style, text and whether each is in a table.

On namespace nexdevit::nexpdf · module conversion · C nexpdf_docx_paragraphs_json

Structured extraction and barcodes

extract_tables_json

std::string extract_tables_json(int32_t page_index, const std::optional<std::string>& options_json = std::nullopt) const

Ruled and unruled tables of a page (every page when the index is negative) with cells, spans, CSV and Markdown. Options {"ruled","unruled","min_unruled_lines"}.

On Document · module conversion · C nexpdf_extract_tables_json

extract_key_values_json

std::string extract_key_values_json(const std::optional<std::string>& options_json = std::nullopt) const

Label/value pairs from the layout and typed entities (dates, amounts, IBANs, e-mails, phones, VAT numbers) with normalised values. Options {"pages","date_order"}.

On Document · module conversion · C nexpdf_extract_key_values_json

extraction_prompt_json

std::string extraction_prompt_json(const std::optional<std::string>& schema_json = std::nullopt, const std::optional<std::string>& options_json = std::nullopt) const

A prompt (system, prompt, response_schema) for extracting a JSON schema with the language model of your choice. The engine makes no network calls.

On Document · module conversion · C nexpdf_extraction_prompt_json

extraction_validate_json

std::string extraction_validate_json(const std::optional<std::string>& schema_json = std::nullopt, const std::optional<std::string>& answer_json = std::nullopt) const

Validates and coerces a model answer against the schema and grounds each value on the pages: valid, value, errors, warnings, fields.

On Document · module conversion · C nexpdf_extraction_validate_json

classify_document_json

std::string classify_document_json(const std::optional<std::string>& labels_json = std::nullopt) const

Classifies the document into one of the given labels by keywords, with scores and a prompt for LLM classification.

On Document · module conversion · C nexpdf_classify_document_json

read_barcodes_json

std::string read_barcodes_json(int32_t page_index, const std::optional<std::string>& options_json = std::nullopt) const

Reads the barcodes of a page (every page when the index is negative): QR, Data Matrix, Aztec, PDF417, Code 128/39/93, EAN/UPC, ITF, Codabar and more, with positions in PDF points.

On Document · module conversion · C nexpdf_read_barcodes_json

read_barcodes_image_json

inline std::string read_barcodes_image_json(const std::vector<uint8_t>& data, const std::optional<std::string>& options_json = std::nullopt)

Reads the barcodes of a PNG or JPEG image, with positions in pixels.

On namespace nexdevit::nexpdf · module conversion · C nexpdf_read_barcodes_image_json

add_barcode

int32_t add_barcode(size_t page_index, double llx, double lly, double urx, double ury, const std::optional<std::string>& format = std::nullopt, const std::optional<std::string>& text = std::nullopt)

Draws text as a vector barcode (white background, quiet zone) into a rectangle of a page, in PDF points.

On Document · module editor · C nexpdf_add_barcode

add_barcode_ex

int32_t add_barcode_ex(size_t page_index, double llx, double lly, double urx, double ury, const std::optional<std::string>& format = std::nullopt, const std::optional<std::string>& text = std::nullopt, const std::optional<std::string>& options_json = std::nullopt)

Draws a vector barcode with options {"human_readable":"auto"|"always"|"never","quiet_zone","background","color"}; auto prints the digits under EAN and UPC codes.

On Document · module editor · C nexpdf_add_barcode_ex

Annotations

add_annotation

int32_t add_annotation(size_t page_index, const std::optional<std::string>& kind, const std::optional<std::string>& color_hex, double opacity, const std::optional<std::string>& contents, double llx, double lly, double urx, double ury)

Adds an annotation. kind is a PDF annotation subtype such as Highlight, Underline, StrikeOut, Squiggly, Square, Circle, FreeText or Text; text markup is fitted to the lines under the rectangle. Colour is #RRGGBB, the rectangle is in PDF points.

On Document · module annotations · C nexpdf_add_annotation

add_ink

int32_t add_ink(size_t page_index, const std::optional<std::string>& color_hex, double stroke_width, double opacity, const std::optional<std::string>& coords = std::nullopt)

Adds a freehand ink annotation. coords is "x,y;x,y;..." in PDF points.

On Document · module annotations · C nexpdf_add_ink

add_line

int32_t add_line(size_t page_index, const std::optional<std::string>& kind, const std::optional<std::string>& color_hex, double opacity, double stroke_width, double x1, double y1, double x2, double y2)

Adds a line or arrow (kind is Line or Arrow) from (x1, y1) to (x2, y2) in PDF points.

On Document · module annotations · C nexpdf_add_line

annotations_json

std::string annotations_json(size_t page_index) const

The annotations of a page as JSON: num, gen, kind, color, contents and the rectangle.

On Document · always available · C nexpdf_annotations_json

remove_annotation

int32_t remove_annotation(size_t page_index, uint32_t num, uint16_t generation)

Removes the annotation with object number num and generation gen from a page.

On Document · module annotations · C nexpdf_remove_annotation

move_annotation

int32_t move_annotation(uint32_t num, uint16_t generation, double dx, double dy)

Moves an annotation by (dx, dy) PDF points.

On Document · module annotations · C nexpdf_move_annotation

set_annotation_contents

int32_t set_annotation_contents(uint32_t num, uint16_t generation, const std::optional<std::string>& contents = std::nullopt)

Replaces the text contents of an annotation.

On Document · module annotations · C nexpdf_set_annotation_contents

export_xfdf

std::string export_xfdf() const

Exports every annotation as an XFDF document.

On Document · module annotations · C nexpdf_export_xfdf

import_xfdf

int32_t import_xfdf(const std::optional<std::string>& xfdf = std::nullopt)

Imports annotations from an XFDF document.

On Document · module annotations · C nexpdf_import_xfdf

flatten_annotations

int32_t flatten_annotations(int32_t page_index)

Burns annotations into the page content. A negative page index flattens every page.

On Document · module annotations · C nexpdf_flatten_annotations

add_image_stamp

int32_t add_image_stamp(size_t page, double llx, double lly, double urx, double ury, const std::vector<uint8_t>& rgba, uint32_t width, uint32_t height, double opacity)

Adds a picture stamp annotation from RGBA pixels (transparency kept). 1 on success.

On Document · module annotations · C nexpdf_add_image_stamp

add_measurement

std::string add_measurement(size_t page, const std::optional<std::string>& json = std::nullopt)

Stores a measurement: {"kind":"distance|perimeter|area","points":[[x,y],...],"unit":"mm","per_point":0.3528,"label":"1:100","color":"#2f54d6"}. Returns {"num","gen","value","text"}.

On Document · module annotations · C nexpdf_add_measurement

measurements_json

std::string measurements_json() const

The stored measurements as JSON.

On Document · always available · C nexpdf_measurements_json

add_file_attachment_annot

int32_t add_file_attachment_annot(size_t page_index, double x, double y, const std::optional<std::string>& name, const std::vector<uint8_t>& data, const std::optional<std::string>& mime = std::nullopt, const std::optional<std::string>& description = std::nullopt)

Adds a paperclip annotation carrying a file; (x, y) is the top-left corner of the icon in PDF points.

On Document · module annotations · C nexpdf_add_file_attachment_annot

add_ink_signature

int32_t add_ink_signature(size_t page_index, const std::optional<std::string>& color_hex, double stroke_width, const std::optional<std::string>& strokes = std::nullopt)

Adds a handwritten signature: an ink annotation with several strokes ("x,y;x,y|x,y;x,y", PDF points) and subject "Signature". Visual only; use a PAdES signature for a cryptographic one.

On Document · module annotations · C nexpdf_add_ink_signature

reply_to_annotation

int32_t reply_to_annotation(size_t page_index, uint32_t num, uint16_t generation, const std::optional<std::string>& author = std::nullopt, const std::optional<std::string>& text = std::nullopt)

Adds a reply by author to an annotation (or to another reply). Returns the reply object number (generation 0).

On Document · module annotations · C nexpdf_reply_to_annotation

annotation_replies_json

std::string annotation_replies_json(size_t page_index, uint32_t num, uint16_t generation) const

The thread under an annotation, oldest first: num, gen, in_reply_to, author, date, text, state, state_model.

On Document · module annotations · C nexpdf_annotation_replies_json

set_annotation_state

int32_t set_annotation_state(size_t page_index, uint32_t num, uint16_t generation, const std::optional<std::string>& author = std::nullopt, const std::optional<std::string>& state = std::nullopt)

Sets a review state (Accepted, Rejected, Cancelled, Completed, None) or marked state (Marked, Unmarked) as a hidden state reply. Returns its object number.

On Document · module annotations · C nexpdf_set_annotation_state

Forms

form_fields_json

std::string form_fields_json() const

The form fields as JSON: name, kind, value, page, rectangle, read_only and required.

On Document · module forms · C nexpdf_form_fields_json

fill_form_field

int32_t fill_form_field(const std::optional<std::string>& name = std::nullopt, const std::optional<std::string>& value = std::nullopt)

Sets a field value as a viewer would: the keystroke and validate scripts check the value, then every calculated field is recomputed. Check boxes take "true" or "false", list fields the option text.

On Document · module forms · C nexpdf_fill_form_field

set_signature_appearance

int32_t set_signature_appearance(const std::optional<std::string>& name, const std::vector<uint8_t>& rgba, uint32_t width, uint32_t height)

Shows a drawn, typed or scanned signature (RGBA pixels) in a signature field without signing digitally; scaled to fit each widget and centred. A later digital signature replaces it.

On Document · module forms · C nexpdf_set_signature_appearance

add_form_field

int32_t add_form_field(size_t page_index, const std::optional<std::string>& kind, const std::optional<std::string>& name, double llx, double lly, double urx, double ury)

Adds a form field named name in a rectangle of a page. kind: text (default), checkbox, radio, combobox, listbox, button, signature or barcode.

On Document · module forms · C nexpdf_add_form_field

flatten_forms

int32_t flatten_forms()

Burns the form fields into the page content.

On Document · module forms · C nexpdf_flatten_forms

recalculate_forms

int32_t recalculate_forms()

Runs every calculate script; returns how many fields changed.

On Document · module forms · C nexpdf_recalculate_forms

export_form_json

std::string export_form_json() const

The field values as a JSON object.

On Document · module forms · C nexpdf_export_form_json

import_form_json

int32_t import_form_json(const std::optional<std::string>& json = std::nullopt)

Fills fields from a JSON object of names and values.

On Document · module forms · C nexpdf_import_form_json

export_form_fdf

std::vector<uint8_t> export_form_fdf(const std::optional<std::string>& pdf_name = std::nullopt) const

The field values as an FDF file; pdf_name is the file name recorded in it.

On Document · module forms · C nexpdf_export_form_fdf

import_form_fdf

int32_t import_form_fdf(const std::vector<uint8_t>& data)

Fills fields from an FDF file.

On Document · module forms · C nexpdf_import_form_fdf

export_form_xfdf

std::string export_form_xfdf(const std::optional<std::string>& pdf_name = std::nullopt) const

The field values as XFDF.

On Document · module forms · C nexpdf_export_form_xfdf

import_form_xfdf

int32_t import_form_xfdf(const std::optional<std::string>& xfdf = std::nullopt)

Fills fields from XFDF.

On Document · module forms · C nexpdf_import_form_xfdf

XFA forms

xfa_info_json

std::string xfa_info_json() const

Whether the document has XFA, whether it is dynamic, field and data counts and the XDP packets.

On Document · module forms · C nexpdf_xfa_info_json

xfa_export_data

std::string xfa_export_data(const std::optional<std::string>& format = std::nullopt) const

The XFA data as xml (default) or flat json ({"path":"value"}). Fails when the document has no XFA.

On Document · module forms · C nexpdf_xfa_export_data

xfa_import_data

int32_t xfa_import_data(const std::optional<std::string>& data = std::nullopt, const std::optional<std::string>& format = std::nullopt)

Imports XFA data: XML replaces the data, JSON sets the given values. Static forms get their AcroForm fields updated. Returns the number of values imported.

On Document · module forms · C nexpdf_xfa_import_data

xfa_to_acroform

int32_t xfa_to_acroform()

Converts to a plain AcroForm PDF and removes XFA; dynamic forms are laid out into new pages and scripts run first. Text fields keep their formatted display value as /V. Returns the number of AcroForm fields.

On Document · module forms · C nexpdf_xfa_to_acroform

xfa_flatten

int32_t xfa_flatten()

Converts and flattens the XFA form: a plain PDF with the values drawn. Returns the number of flattened widgets.

On Document · module forms · C nexpdf_xfa_flatten

xfa_remove

int32_t xfa_remove()

Removes XFA and keeps the AcroForm fields and pages: 1 removed, 0 no XFA.

On Document · module forms · C nexpdf_xfa_remove

xfa_to_acroform_json

std::string xfa_to_acroform_json(const std::optional<std::string>& options_json = std::nullopt)

Converts to AcroForm with options {"scripts":true,"flatten":false} and returns a report: flattened, fields, pages, warnings and validation_errors (som, test, severity, message).

On Document · module forms · C nexpdf_xfa_to_acroform_json

xfa_run_scripts_json

std::string xfa_run_scripts_json()

Runs the initialize, calculate and validate scripts (FormCalc and JavaScript) and stores calculated values in the data: data_changed, warnings, validation_errors.

On Document · module forms · C nexpdf_xfa_run_scripts_json

register_fallback_font

inline int32_t register_fallback_font(const std::vector<uint8_t>& data)

Registers a TrueType/OpenType font (or .ttc) for text the bundled fonts cannot show (CJK, Arabic and more) when XFA forms are laid out; the data is copied. 1, or -1.

On namespace nexdevit::nexpdf · module forms · C nexpdf_register_fallback_font

Real-time collaboration

sync_export_json

std::string sync_export_json(uint64_t since_version)

NexPDF Sync: every change (from any client) with a Lamport clock above since_version, as a nexpdf-sync/1 change set.

On Document · module annotations · C nexpdf_sync_export_json

sync_export_local_json

std::string sync_export_local_json(uint64_t since_version)

NexPDF Sync: only this copy's own changes above since_version (what a client pushes); keep the returned clock for the next call.

On Document · module annotations · C nexpdf_sync_export_local_json

sync_apply_json

std::string sync_apply_json(const std::optional<std::string>& changes_json = std::nullopt)

NexPDF Sync: applies remote changes, last writer wins per record. Returns ok, clock, applied, ignored, conflicts and errors.

On Document · module annotations · C nexpdf_sync_apply_json

sync_snapshot_json

std::string sync_snapshot_json()

NexPDF Sync: every record with its version, base records and tombstones included.

On Document · module annotations · C nexpdf_sync_snapshot_json

sync_set_client_id

int32_t sync_set_client_id(const std::optional<std::string>& client_id = std::nullopt)

NexPDF Sync: the client id this copy versions its changes under (1 to 64 characters of [A-Za-z0-9-_.:@]).

On Document · module annotations · C nexpdf_sync_set_client_id

Page editing

rotate_page

int32_t rotate_page(size_t page_index, int32_t degrees)

Rotates a page by a multiple of 90 degrees.

On Document · module editor · C nexpdf_rotate_page

delete_page

int32_t delete_page(size_t page_index)

Deletes a page.

On Document · module editor · C nexpdf_delete_page

duplicate_page

int32_t duplicate_page(size_t page_index)

Inserts a copy of a page after it.

On Document · module editor · C nexpdf_duplicate_page

add_blank_page

int32_t add_blank_page()

Appends a blank page.

On Document · module editor · C nexpdf_add_blank_page

reverse_pages

int32_t reverse_pages()

Reverses the page order.

On Document · module editor · C nexpdf_reverse_pages

move_page

int32_t move_page(size_t from, size_t to)

Moves the page at from to index to.

On Document · module editor · C nexpdf_move_page

crop_page

int32_t crop_page(size_t page_index, double llx, double lly, double urx, double ury)

Sets the crop box of a page (PDF points).

On Document · module editor · C nexpdf_crop_page

extract_pages

Document extract_pages(const std::vector<uint32_t>& indices) const

A new document made of the given pages (split).

On Document · module editor · C nexpdf_extract_pages

append_document

int32_t append_document(const Document& other)

Appends the pages of another document (merge).

On Document · module editor · C nexpdf_append_document

insert_image_pages

int32_t insert_image_pages(size_t index, const std::vector<uint8_t>& data)

Inserts the pictures of a JPEG, PNG or TIFF file as pages before index (clamped; the page count appends). Returns the number of pages added.

On Document · always available · C nexpdf_insert_image_pages

set_page_background

int32_t set_page_background(const std::optional<std::string>& options_json, const std::vector<uint8_t>& rgb, uint32_t width, uint32_t height)

Sets a page background: a colour and/or an RGB picture. Options: {"color":"#fbf4e2","fit":"cover|stretch|center","scale":1,"opacity":1,"pages":[]}. Returns the pages changed.

On Document · module editor · C nexpdf_set_page_background

remove_page_background

int32_t remove_page_background(const std::optional<std::string>& pages_json = std::nullopt)

Removes NexPDF backgrounds from the pages in pages_json ("[0,2]"), or from every page.

On Document · module editor · C nexpdf_remove_page_background

Content editing

page_content_json

std::string page_content_json(size_t page) const

The text lines and images of a page as JSON: id, kind (text or image), text, rect, size, color, font, family, bold, italic. Ids stay valid until the next edit of that page.

On Document · module editor · C nexpdf_page_content_json

edit_text

int32_t edit_text(size_t page, const std::optional<std::string>& id = std::nullopt, const std::optional<std::string>& change_json = std::nullopt)

Edits a text line: {text?, size?, color?, dx?, dy?, family?, bold?, italic?}. Empty text deletes it.

On Document · module editor · C nexpdf_edit_text

add_page_text

int32_t add_page_text(size_t page, const std::optional<std::string>& json = std::nullopt)

Adds editable page text: {text, x, y (baseline), size, color, family, bold, italic}.

On Document · module editor · C nexpdf_add_page_text

delete_content

int32_t delete_content(size_t page, const std::optional<std::string>& id = std::nullopt)

Deletes a text line or an image of the page content.

On Document · module editor · C nexpdf_delete_content

transform_image

int32_t transform_image(size_t page, const std::optional<std::string>& id, double llx, double lly, double urx, double ury)

Moves or resizes an image to a rectangle (PDF points).

On Document · module editor · C nexpdf_transform_image

replace_image

int32_t replace_image(size_t page, const std::optional<std::string>& id, const std::vector<uint8_t>& rgb, uint32_t width, uint32_t height)

Replaces an image with RGB pixels (width x height x 3 bytes).

On Document · module editor · C nexpdf_replace_image

edit_text_block

int32_t edit_text_block(size_t page_index, const std::optional<std::string>& text, const std::optional<std::string>& color_hex, double font_size, int32_t bold, int32_t italic, int32_t replace_existing, double llx, double lly, double urx, double ury)

Writes a text block into a rectangle with colour, size and style, optionally replacing the text already there.

On Document · module editor · C nexpdf_edit_text_block

Metadata, bookmarks, layers and attachments

metadata_json

std::string metadata_json() const

The document information (title, author, subject, keywords, ...) as JSON.

On Document · always available · C nexpdf_metadata_json

set_metadata

int32_t set_metadata(const std::optional<std::string>& title = std::nullopt, const std::optional<std::string>& author = std::nullopt, const std::optional<std::string>& subject = std::nullopt, const std::optional<std::string>& keywords = std::nullopt)

Sets the title, author, subject and keywords. Omitted (null) values keep the current one.

On Document · module editor · C nexpdf_set_metadata

outlines_json

std::string outlines_json() const

The bookmarks as JSON: [{"title","page","children":[...]}].

On Document · always available · C nexpdf_outlines_json

set_outlines_json

int32_t set_outlines_json(const std::optional<std::string>& json = std::nullopt)

Replaces the bookmarks with a JSON tree in the same shape.

On Document · module editor · C nexpdf_set_outlines_json

page_labels_json

std::string page_labels_json() const

Page labels: {"labels":["i","ii","1"],"ranges":[{"start":0,"style":"roman","prefix":"","first":1}]}.

On Document · always available · C nexpdf_page_labels_json

set_page_labels_json

int32_t set_page_labels_json(const std::optional<std::string>& json = std::nullopt)

Sets the page label ranges ([] removes the labels). Styles: decimal, roman, ROMAN, letters, LETTERS, none.

On Document · module editor · C nexpdf_set_page_labels_json

layers_json

std::string layers_json() const

The optional content groups (layers): [{"num","gen","name","visible","printable"}].

On Document · always available · C nexpdf_layers_json

set_layer_visible

int32_t set_layer_visible(uint32_t num, uint16_t generation, int32_t visible)

Shows or hides a layer.

On Document · always available · C nexpdf_set_layer_visible

attachments_json

std::string attachments_json() const

The embedded files: [{"name","description","mime","size","page"}]; page is null for document-level files.

On Document · always available · C nexpdf_attachments_json

attachment_data

std::vector<uint8_t> attachment_data(const std::optional<std::string>& name = std::nullopt) const

The bytes of an embedded file.

On Document · always available · C nexpdf_attachment_data

add_attachment

int32_t add_attachment(const std::optional<std::string>& name, const std::vector<uint8_t>& data, const std::optional<std::string>& mime = std::nullopt, const std::optional<std::string>& description = std::nullopt)

Embeds a file at document level.

On Document · module editor · C nexpdf_add_attachment

remove_attachment

int32_t remove_attachment(const std::optional<std::string>& name = std::nullopt)

Removes an embedded file.

On Document · module editor · C nexpdf_remove_attachment

Encryption, watermarks and stamping

encrypt_aes256

int32_t encrypt_aes256(const std::optional<std::string>& user_pw = std::nullopt, const std::optional<std::string>& owner_pw = std::nullopt)

Encrypts with AES-256 using a user (open) password and an owner password.

On Document · module security · C nexpdf_encrypt_aes256

encrypt_with_permissions

int32_t encrypt_with_permissions(const std::optional<std::string>& user_pw, const std::optional<std::string>& owner_pw, uint32_t permissions)

Encrypts with AES-256 and a permission mask: print 1, modify 2, copy 4, annotate 8, fill forms 16, assemble 32.

On Document · module security · C nexpdf_encrypt_with_permissions

security_json

std::string security_json() const

The encryption state: {"encrypted","revision","owner","print","modify","copy","annotate","fill_forms","assemble"}.

On Document · always available · C nexpdf_security_json

remove_password

int32_t remove_password(const std::optional<std::string>& password = std::nullopt)

Removes the protection. Needs owner access: the document was opened with the owner password, or pass it here.

On Document · module security · C nexpdf_remove_password

add_watermark

int32_t add_watermark(const std::optional<std::string>& text = std::nullopt)

Stamps a text watermark on every page.

On Document · module security · C nexpdf_add_watermark

remove_watermarks

int32_t remove_watermarks()

Removes the watermarks NexPDF added.

On Document · module security · C nexpdf_remove_watermarks

int32_t add_header_footer(const std::optional<std::string>& header, const std::optional<std::string>& footer, double font_size)

Adds a header and/or footer to every page. {page} and {total} are replaced; a font size of 0 or less uses the default.

On Document · module security · C nexpdf_add_header_footer

add_bates

int32_t add_bates(const std::optional<std::string>& prefix, uint64_t start, uint32_t digits)

Adds Bates numbering: prefix, first number and number of digits.

On Document · module security · C nexpdf_add_bates

Redaction

apply_redaction

int32_t apply_redaction(size_t page_index, double llx, double lly, double urx, double ury, int32_t fill_white)

Permanently removes the text, images and annotations under a rectangle and paints an opaque box over it, black or white.

On Document · module redaction · C nexpdf_apply_redaction

redact_matches

int32_t redact_matches(const std::optional<std::string>& query, int32_t mode, int32_t fill_white)

Finds and permanently redacts every match. mode: 0 = text, 1 = regular expression, 2 = pattern id (email, phone, credit-card, iban, pt-nif, us-ssn, ipv4, url, date). Returns the number of areas redacted.

On Document · module redaction · C nexpdf_redact_matches

Digital signatures

sign_pades

std::vector<uint8_t> sign_pades(const std::optional<std::string>& signer = std::nullopt, const std::optional<std::string>& reason = std::nullopt, const std::optional<std::string>& location = std::nullopt) const

Signs with a new self-signed test certificate (PAdES B-B) and returns the signed file. Write the bytes as they are: saving the document again breaks the signature.

On Document · module signatures · C nexpdf_sign_pades

sign_pkcs12

std::vector<uint8_t> sign_pkcs12(const std::vector<uint8_t>& p12, const std::optional<std::string>& password = std::nullopt, const std::optional<std::string>& options_json = std::nullopt) const

Signs with a PKCS#12 (.p12/.pfx) identity and returns the signed file. Options: {"name","reason","location","contact","field","tsa_url","ltv":true,"appearance":{"page":0,"rect":[llx,lly,urx,ury],"ink":"x,y;x,y|...","text":"..."}}. Without a .p12 a self-signed certificate is created.

On Document · module signatures · C nexpdf_sign_pkcs12

pkcs12_info_json

inline std::string pkcs12_info_json(const std::vector<uint8_t>& data, const std::optional<std::string>& password = std::nullopt)

The certificate summary of a PKCS#12 file; fails with "incorrect password" on a wrong password.

On namespace nexdevit::nexpdf · module signatures · C nexpdf_pkcs12_info_json

prepare_external_signature

std::vector<uint8_t> prepare_external_signature(const std::vector<uint8_t>& cert, const std::optional<std::string>& options_json = std::nullopt) const

External signing (HSM, smart card, cloud KMS), step 1: a PDF with an empty signature for the signer certificate (PEM or DER, optionally followed by its chain). Options as for PKCS#12 signing.

On Document · module signatures · C nexpdf_prepare_external_signature

external_signature_data

inline std::vector<uint8_t> external_signature_data(const std::vector<uint8_t>& prepared, const std::vector<uint8_t>& cert)

External signing, step 2: the bytes to sign (DER signed attributes; sign their SHA-256 on devices that take a digest).

On namespace nexdevit::nexpdf · module signatures · C nexpdf_external_signature_data

complete_external_signature

inline std::vector<uint8_t> complete_external_signature(const std::vector<uint8_t>& prepared, const std::vector<uint8_t>& cert, const std::vector<uint8_t>& signature, int32_t algorithm, const std::optional<std::string>& options_json = std::nullopt)

External signing, step 3: embeds the signature and returns the signed PDF. algorithm: 0 RSA PKCS#1 v1.5 SHA-256, 1 ECDSA SHA-256. Options: {"tsa_url":"...","ltv":true}.

On namespace nexdevit::nexpdf · module signatures · C nexpdf_complete_external_signature

verify_signatures_json

inline std::string verify_signatures_json(const std::vector<uint8_t>& data)

Verifies every signature of a signed file (its exact bytes). Each entry has field, signer, subject, digest_ok, signature_ok, covers_whole_document, reason, signing_time, timestamp_ok, chain_ok, trusted, revocation, ltv, level and more.

On namespace nexdevit::nexpdf · always available · C nexpdf_verify_signatures_json

verify_signatures_with_roots_json

inline std::string verify_signatures_with_roots_json(const std::vector<uint8_t>& data, const std::optional<std::string>& roots_pem = std::nullopt)

Verifies the signatures treating the PEM certificates in roots_pem as trust anchors.

On namespace nexdevit::nexpdf · module signatures · C nexpdf_verify_signatures_with_roots_json

add_ltv

inline std::vector<uint8_t> add_ltv(const std::vector<uint8_t>& data)

Adds long-term validation data (DSS with OCSP responses and CRLs) to a signed file.

On namespace nexdevit::nexpdf · module signatures · C nexpdf_add_ltv

add_document_timestamp

std::vector<uint8_t> add_document_timestamp(const std::optional<std::string>& options_json = std::nullopt) const

Adds an RFC 3161 document timestamp from a TSA (PAdES B-LTA). Options: {"tsa_url" (required),"hash","field","reserved","ltv"}; with ltv the validation data of earlier signatures goes into the DSS first. Returns the new file.

On Document · module signatures · C nexpdf_add_document_timestamp

add_document_timestamp_bytes

inline std::vector<uint8_t> add_document_timestamp_bytes(const std::vector<uint8_t>& data, const std::optional<std::string>& options_json = std::nullopt)

Adds a document timestamp to the bytes of a PDF file (for example straight from signing). Same options. Returns the new file.

On namespace nexdevit::nexpdf · module signatures · C nexpdf_add_document_timestamp_bytes

prepare_document_timestamp

std::vector<uint8_t> prepare_document_timestamp(const std::optional<std::string>& options_json = std::nullopt) const

Document timestamp from your own TSA or HSM, step 1: the PDF with an empty timestamp (options as for adding one, without tsa_url).

On Document · module signatures · C nexpdf_prepare_document_timestamp

document_timestamp_request

inline std::vector<uint8_t> document_timestamp_request(const std::vector<uint8_t>& prepared, const std::optional<std::string>& hash = std::nullopt)

Document timestamp, step 2: the DER TimeStampReq to send to the TSA as application/timestamp-query (hash SHA-256 by default).

On namespace nexdevit::nexpdf · module signatures · C nexpdf_document_timestamp_request

complete_document_timestamp

inline std::vector<uint8_t> complete_document_timestamp(const std::vector<uint8_t>& prepared, const std::vector<uint8_t>& token)

Document timestamp, step 3: the timestamped PDF, from the prepared file and the TSA token (TimeStampResp or TimeStampToken).

On namespace nexdevit::nexpdf · module signatures · C nexpdf_complete_document_timestamp

signature_timestamp_request

inline std::vector<uint8_t> signature_timestamp_request(const std::vector<uint8_t>& data, const std::optional<std::string>& hash = std::nullopt)

B-T in steps: the DER TimeStampReq over the value of the last signature (SHA-256 by default), to POST to the TSA as application/timestamp-query.

On namespace nexdevit::nexpdf · module signatures · C nexpdf_signature_timestamp_request

add_signature_timestamp

inline std::vector<uint8_t> add_signature_timestamp(const std::vector<uint8_t>& data, const std::vector<uint8_t>& token)

B-T in steps: stores the TSA answer (TimeStampResp or TimeStampToken) in the last signature, signed bytes unchanged, and returns the PDF.

On namespace nexdevit::nexpdf · module signatures · C nexpdf_add_signature_timestamp

ltv_requests_json

inline std::string ltv_requests_json(const std::vector<uint8_t>& data, const std::optional<std::string>& responses_json = std::nullopt)

B-LT in steps: the HTTP requests (OCSP, CRL, certificates) the validation data still needs, given the answers so far; [] when nothing is missing.

On namespace nexdevit::nexpdf · module signatures · C nexpdf_ltv_requests_json

add_ltv_with_responses

inline std::vector<uint8_t> add_ltv_with_responses(const std::vector<uint8_t>& data, const std::optional<std::string>& responses_json = std::nullopt)

B-LT in steps: adds the /DSS from the fetched answers (missing ones count as failed) as an incremental update and returns the PDF.

On namespace nexdevit::nexpdf · module signatures · C nexpdf_add_ltv_with_responses

validate_lta_json

inline std::string validate_lta_json(const std::vector<uint8_t>& data, const std::optional<std::string>& trust_roots_pem = std::nullopt)

Full PAdES B-LTA validation: whether the /DSS of each time-stamped revision holds every certificate and verified OCSP or CRL entry the earlier signatures and time-stamps need. Returns complete and timestamps with their issues.

On namespace nexdevit::nexpdf · module signatures · C nexpdf_validate_lta_json

PDF/A, PDF/X and PDF/UA

convert_pdfa

int32_t convert_pdfa()

Converts the document to PDF/A (ISO 19005) for archiving.

On Document · module standards · C nexpdf_convert_pdfa

convert_pdfx

int32_t convert_pdfx()

Converts the document to PDF/X for print exchange.

On Document · module standards · C nexpdf_convert_pdfx

auto_tag

std::string auto_tag(const std::optional<std::string>& lang, int32_t force)

Tags the document for accessibility (PDF/UA structure tree, language, title, metadata). lang is a BCP 47 tag (default en-US); force re-tags a document that is already tagged. Returns a JSON report.

On Document · module standards · C nexpdf_auto_tag

validate_pdfa_json

std::string validate_pdfa_json(const std::optional<std::string>& level = std::nullopt) const

Rule-based PDF/A validation for 1a to 4f (the declared level, or 2b, when empty): compliant, level and failures with clause, message, page and object.

On Document · module standards · C nexpdf_validate_pdfa_json

validate_pdfua_json

std::string validate_pdfua_json() const

PDF/UA validation (PDF/UA-1, or PDF/UA-2 when declared), with the same report as PDF/A validation.

On Document · module standards · C nexpdf_validate_pdfua_json

convert_pdfa_level

int32_t convert_pdfa_level(const std::optional<std::string>& level = std::nullopt)

Converts to a chosen PDF/A level (2b when empty); level A tags the document first. 1 when the result validates; otherwise the error lists the clauses still failing.

On Document · module standards · C nexpdf_convert_pdfa_level

convert_pdfa_json

std::string convert_pdfa_json(const std::optional<std::string>& level, double flatten_dpi, int32_t substitute_fonts)

Converts to a PDF/A level (1a to 4f, 2b when empty) and returns the report: level, compliant, fixed, substitutions and remaining. flatten_dpi is the resolution PDF/A-1 transparency is flattened at (300 when 0 or less); substitute_fonts 0 leaves non-embedded fonts alone.

On Document · module standards · C nexpdf_convert_pdfa_json

convert_pdfua_json

std::string convert_pdfua_json(int32_t part, const std::optional<std::string>& lang = std::nullopt)

Converts to PDF/UA-1 or PDF/UA-2 (part 1 or 2): tags an untagged document, embeds fonts and, for part 2, uses the PDF 2.0 namespaces. lang (en-US when empty) applies when the document has none. Returns profile, compliant, fixed, warnings, substitutions, remaining.

On Document · module standards · C nexpdf_convert_pdfua_json

validate_pdfua_part_json

std::string validate_pdfua_part_json(int32_t part) const

Validates against PDF/UA-1 or PDF/UA-2 (part 1 or 2) whatever the document declares, with the same report as PDF/UA validation.

On Document · module standards · C nexpdf_validate_pdfua_part_json

register_substitute_font

inline std::string register_substitute_font(const std::vector<uint8_t>& data)

Registers TrueType font data for PDF/A and PDF/UA font substitution: non-embedded fonts with the same PostScript or family name use it. Returns the PostScript name, or nothing when the data is not a TrueType font with glyf outlines.

On namespace nexdevit::nexpdf · module standards · C nexpdf_register_substitute_font

OCR

ocr

std::string ocr(const std::optional<std::string>& options_json = std::nullopt)

Recognises scanned pages and adds an invisible, searchable text layer. Options (may be omitted): {"engine":"auto|builtin|tesseract|neural","languages":"por+eng","dpi":300,"pages":[0],"force":false}. Returns a JSON report.

On Document · module ocr · C nexpdf_ocr

ocr_load_model

inline int32_t ocr_load_model(const std::optional<std::string>& options_json, const std::vector<uint8_t>& model, const std::optional<std::string>& dictionary = std::nullopt)

Loads a neural OCR model (ONNX) at run time: {"kind":"detection"|"recognition"|"classification","languages","name","input_height","max_side"}; a recognition model needs its character dictionary, a detection model or a text-direction classifier (0°/180°) takes none.

On namespace nexdevit::nexpdf · module ocr · C nexpdf_ocr_load_model

ocr_models_json

inline std::string ocr_models_json()

Unloads the OCR models of the given languages (all when empty). Returns the number removed.

On namespace nexdevit::nexpdf · module ocr · C nexpdf_ocr_unload_models

ocr_unload_models

inline int32_t ocr_unload_models(const std::optional<std::string>& languages = std::nullopt)

Unloads the OCR models of the given languages (all when empty). Returns the number removed.

On namespace nexdevit::nexpdf · module ocr · C nexpdf_ocr_unload_models

Compare, optimise and memory

compare_json

std::string compare_json(const Document& b, double dpi) const

Compares two documents (text and visual differences per page) at the given resolution, as JSON.

On Document · always available · C nexpdf_compare_json

compare_overlay_png

std::vector<uint8_t> compare_overlay_png(const Document& b, size_t page_index, double dpi) const

A PNG overlay of the visual differences of one page of two documents.

On Document · always available · C nexpdf_compare_overlay_png

optimize

std::string optimize()

Optimises the document (removes unused objects, recompresses streams); returns a JSON report.

On Document · module editor · C nexpdf_optimize

subset_fonts

std::string subset_fonts()

Subsets the embedded fonts to the glyphs the document uses; returns a JSON report.

On Document · module editor · C nexpdf_subset_fonts

trim_memory

size_t trim_memory()

Drops cached data of the document; returns the bytes freed.

On Document · always available · C nexpdf_trim_memory

memory_usage_bytes

size_t memory_usage_bytes() const

Approximate memory used by the document, in bytes.

On Document · always available · C nexpdf_memory_usage_bytes

compare_text_json

std::string compare_text_json(const Document& b, const std::optional<std::string>& options_json = std::nullopt) const

Word-level text comparison of two documents: inserted, deleted, replaced and moved text with positions, and a summary. Options {"ignore_case","ignore_punctuation","detect_moves","min_move_words","align","page_map"}.

On Document · always available · C nexpdf_compare_text_json

compare_annotate

std::vector<uint8_t> compare_annotate(const Document& b, const std::optional<std::string>& options_json = std::nullopt) const

The word-level comparison as a new PDF with highlight annotations (deleted red, inserted green, moved blue). Options add output, author and the colours.

On Document · always available · C nexpdf_compare_annotate

Other

set_annotation_flags

int32_t set_annotation_flags(uint32_t num, uint16_t generation, const std::optional<std::string>& flags_json = std::nullopt)

Annotation flags (/F). flags_json: {"readonly":true,"print":false} changes only the flags it names; ["print","locked"] sets exactly these; a number is the bitmask. Names: invisible, hidden, print, nozoom, norotate, noview, readonly, locked, togglenoview, lockedcontents. XFDF import and export keep them (flags="print,readonly"). 1 on success.

On Document

set_annotation_style

int32_t set_annotation_style(uint32_t num, uint16_t generation, const std::optional<std::string>& style_json = std::nullopt)

Colour, opacity and border width, then a new appearance: {"color":"#RRGGBB","opacity":0.5, "border_width":2}, every key optional (a missing key keeps the current value). 1 on success.

On Document

On this page

Setup and lifecycleopen_bytesopenhandlesavecopyresetversionactivate_licensetsa_trampolineset_tsa_callbackclear_tsa_callbackis_licensedLibrary and licensinglicense_status_jsoninvokeregister_standard_fontOpening and savingopen_bytes_with_passwordfrom_htmlhas_bundled_fontsopen_officeopen_ebookopen_imagesave_bytessave_linearizedPages and renderingpage_countpage_widthpage_heightpage_view_jsonrender_page_pngrender_thumb_pngset_overprintText, search and assistantextract_page_textextract_markdownsearch_jsonpage_blocks_jsonask_documentpage_words_jsonConversionto_htmlto_jsonto_xmlto_csvto_rtfto_docxto_xlsxto_pptxto_reflow_htmlopen_xlsx_with_clockopen_docx_with_options_jsonTemplatestemplate_docx_to_pdftemplate_docx_filltemplate_html_to_pdftemplate_fill_pdftemplate_docx_fill_withOffice editingxlsx_editxlsx_cells_jsondocx_editdocx_paragraphs_jsonStructured extraction and barcodesextract_tables_jsonextract_key_values_jsonextraction_prompt_jsonextraction_validate_jsonclassify_document_jsonread_barcodes_jsonread_barcodes_image_jsonadd_barcodeadd_barcode_exAnnotationsadd_annotationadd_inkadd_lineannotations_jsonremove_annotationmove_annotationset_annotation_contentsexport_xfdfimport_xfdfflatten_annotationsadd_image_stampadd_measurementmeasurements_jsonadd_file_attachment_annotadd_ink_signaturereply_to_annotationannotation_replies_jsonset_annotation_stateFormsform_fields_jsonfill_form_fieldset_signature_appearanceadd_form_fieldflatten_formsrecalculate_formsexport_form_jsonimport_form_jsonexport_form_fdfimport_form_fdfexport_form_xfdfimport_form_xfdfXFA formsxfa_info_jsonxfa_export_dataxfa_import_dataxfa_to_acroformxfa_flattenxfa_removexfa_to_acroform_jsonxfa_run_scripts_jsonregister_fallback_fontReal-time collaborationsync_export_jsonsync_export_local_jsonsync_apply_jsonsync_snapshot_jsonsync_set_client_idPage editingrotate_pagedelete_pageduplicate_pageadd_blank_pagereverse_pagesmove_pagecrop_pageextract_pagesappend_documentinsert_image_pagesset_page_backgroundremove_page_backgroundContent editingpage_content_jsonedit_textadd_page_textdelete_contenttransform_imagereplace_imageedit_text_blockMetadata, bookmarks, layers and attachmentsmetadata_jsonset_metadataoutlines_jsonset_outlines_jsonpage_labels_jsonset_page_labels_jsonlayers_jsonset_layer_visibleattachments_jsonattachment_dataadd_attachmentremove_attachmentEncryption, watermarks and stampingencrypt_aes256encrypt_with_permissionssecurity_jsonremove_passwordadd_watermarkremove_watermarksadd_header_footeradd_batesRedactionapply_redactionredact_matchesDigital signaturessign_padessign_pkcs12pkcs12_info_jsonprepare_external_signatureexternal_signature_datacomplete_external_signatureverify_signatures_jsonverify_signatures_with_roots_jsonadd_ltvadd_document_timestampadd_document_timestamp_bytesprepare_document_timestampdocument_timestamp_requestcomplete_document_timestampsignature_timestamp_requestadd_signature_timestampltv_requests_jsonadd_ltv_with_responsesvalidate_lta_jsonPDF/A, PDF/X and PDF/UAconvert_pdfaconvert_pdfxauto_tagvalidate_pdfa_jsonvalidate_pdfua_jsonconvert_pdfa_levelconvert_pdfa_jsonconvert_pdfua_jsonvalidate_pdfua_part_jsonregister_substitute_fontOCRocrocr_load_modelocr_models_jsonocr_unload_modelsCompare, optimise and memorycompare_jsoncompare_overlay_pngoptimizesubset_fontstrim_memorymemory_usage_bytescompare_text_jsoncompare_annotateOtherset_annotation_flagsset_annotation_style