API reference
Every class, method and function of the NexPDF Rust SDK, grouped by feature. Generated from NexPDF 1.1.0.
Generated from NexPDF 1.1.0
This page is generated from the sources of nexpdf-sdk (use nexpdf_sdk). It lists 244 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.
Calls return nexpdf_sdk::Result<T>. With the serde feature, every *_json call also has a *_json_value twin that returns a serde_json::Value.
Setup and lifecycle
from_bytes_with_password
pub fn from_bytes_with_password(data: &[u8], password: &str) -> Result<Document>Like from_bytes, opening an encrypted PDF with password (Office files, books and comics carry no PDF password and ignore it).
On Document
open
pub fn open(path: impl AsRef<Path>) -> Result<Document>Reads and opens a file; see from_bytes.
On Document
open_with_password
pub fn open_with_password(path: impl AsRef<Path>, password: &str) -> Result<Document>Reads and opens an encrypted file; see from_bytes_with_password.
On Document
save
pub fn save(&self, path: impl AsRef<Path>) -> Result<()>Writes the document to path.
On Document
save_linearized_to
pub fn save_linearized_to(&self, path: impl AsRef<Path>) -> Result<()>Writes a linearized ("Fast Web View") file to path.
On Document
try_clone
pub fn try_clone(&self) -> Result<Document>An independent copy (for undo snapshots, or to work on another thread).
On Document
as_ptr
pub fn as_ptr(&self) -> *const sys::NexPdfDocumentThe raw handle, for calling sys functions that take a const NexPdfDocument *.
On Document
as_mut_ptr
pub fn as_mut_ptr(&mut self) -> *mut sys::NexPdfDocumentThe raw handle, for calling sys functions that modify the document.
On Document
into_raw
pub fn into_raw(self) -> *mut sys::NexPdfDocumentGives up ownership; free the handle with sys::nexpdf_free.
On Document
status_json
pub fn status_json() -> Result<String>The active license as JSON (nexpdf_license_status_json), including its "modules".
On nexpdf_sdk::license
is_licensed
pub fn is_licensed(module: &str) -> boolWhether the active license unlocks module (annotations, forms, editor, security, redaction, signatures, conversion, ocr, standards).
On nexpdf_sdk::license
zip_kind
pub fn zip_kind(data: &[u8]) -> ZipKindClassifies data. Reads the entry names from the ZIP's central directory; never decompresses.
On nexpdf_sdk
Library and licensing
version
pub fn version() -> StringThe engine version.
On nexpdf_sdk · always available · C nexpdf_version
activate
pub fn activate(key_or_xml: &str, platform: &str, app_id: &str) -> Result<Activation>Activates a license key or license XML for the process. Returns 2 (licensed), 1 (trial) or a negative error code (-1 malformed, -2 bad signature, -3 unsupported version, -4 expired, -5 not yet valid, -6 wrong platform, -7 wrong app id).
On nexpdf_sdk::license · always available · C nexpdf_license_activate
license_status_json
pub fn license_status_json() -> Result<String>The active license as JSON: state (unlicensed, trial or licensed), licensee, id, tier, modules, expires_at, days_left and watermark.
On nexpdf_sdk · always available · C nexpdf_license_status_json
license_status_json_value
pub fn license_status_json_value() -> Result<serde_json::Value>The active license as JSON: state (unlicensed, trial or licensed), licensee, id, tier, modules, expires_at, days_left and watermark.
On nexpdf_sdk · always available · C nexpdf_license_status_json
last_error
pub fn last_error() -> Option<String>Why the last call on this thread failed, or nothing.
On nexpdf_sdk · always available · C nexpdf_last_error
invoke
pub fn invoke(request_json: impl StrArg) -> Result<String>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 nexpdf_sdk · always available · C nexpdf_invoke
register_standard_font
pub fn register_standard_font(data: &[u8]) -> Result<i32>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 nexpdf_sdk · always available · C nexpdf_register_standard_font
has_bundled_fonts
pub fn has_bundled_fonts() -> Result<i32>1 when the Liberation fonts are compiled in, 0 in the lighter builds.
On nexpdf_sdk · always available · C nexpdf_has_bundled_fonts
Opening and saving
from_bytes
pub fn from_bytes(data: &[u8]) -> Result<Document>Opens a PDF from bytes. JPEG, PNG and TIFF pictures are also accepted (one page per picture).
On Document · always available · C nexpdf_open_bytes
open_bytes_with_password
pub fn open_bytes_with_password(data: &[u8], password: impl StrArg) -> Result<Document>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 Document · always available · C nexpdf_open_bytes_with_password
from_html
pub fn from_html(html: impl StrArg) -> Result<Document>Lays out HTML as a new PDF document.
On Document · module conversion · C nexpdf_from_html
open_office
pub fn open_office(data: &[u8]) -> Result<Document>Converts Word, Excel or PowerPoint bytes (format detected) to a new PDF document.
On Document · module conversion · C nexpdf_open_office
open_ebook
pub fn open_ebook(data: &[u8]) -> Result<Document>Converts EPUB, FictionBook (.fb2, .fb2.zip), XPS/OpenXPS or a CBZ comic archive to a new PDF document.
On Document · module conversion · C nexpdf_open_ebook
open_image
pub fn open_image(data: &[u8]) -> Result<Document>Converts JPEG, PNG or TIFF bytes to a new PDF, one page per picture.
On Document · always available · C nexpdf_open_image
save_bytes
pub fn save_bytes(&self) -> Result<Vec<u8>>The document, with every change, as PDF bytes (full rewrite).
On Document · always available · C nexpdf_save_bytes
save_linearized
pub fn save_linearized(&self) -> Result<Vec<u8>>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
pub fn page_count(&self) -> Result<i32>Number of pages.
On Document · always available · C nexpdf_page_count
page_width
pub fn page_width(&self, page_index: usize) -> f64Displayed page width in points (crop box, rotation and /UserUnit applied).
On Document · always available · C nexpdf_page_width
page_height
pub fn page_height(&self, page_index: usize) -> f64Displayed page height in points (crop box, rotation and /UserUnit applied).
On Document · always available · C nexpdf_page_height
page_view_json
pub fn page_view_json(&self, page_index: usize) -> Result<String>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
page_view_json_value
pub fn page_view_json_value(&self, page_index: usize) -> Result<serde_json::Value>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
pub fn render_page_png(&self, page_index: usize, dpi: f64) -> Result<Vec<u8>>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
pub fn render_thumb_png(&self, page_index: usize, max_dim: u32) -> Result<Vec<u8>>Renders a thumbnail PNG whose longer side is at most max_dim pixels.
On Document · always available · C nexpdf_render_thumb_png
set_overprint
pub fn set_overprint(&mut self, mode: i32) -> Result<i32>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
pub fn extract_page_text(&self, page_index: usize) -> Result<String>The text of a page in reading order.
On Document · always available · C nexpdf_extract_page_text
extract_markdown
pub fn extract_markdown(&self) -> Result<String>The whole document as Markdown (headings, lists, tables).
On Document · always available · C nexpdf_extract_markdown
search_json
pub fn search_json(&self, query: impl StrArg) -> Result<String>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
search_json_value
pub fn search_json_value(&self, query: impl StrArg) -> Result<serde_json::Value>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
pub fn page_blocks_json(&self, page_index: usize) -> Result<String>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
page_blocks_json_value
pub fn page_blocks_json_value(&self, page_index: usize) -> Result<serde_json::Value>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
pub fn ask_document(&self, question: impl StrArg, k: u32, max_chars: u32) -> Result<String>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
pub fn page_words_json(&self, page_index: usize, options_json: impl StrArg) -> Result<String>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
page_words_json_value
pub fn page_words_json_value( &self, page_index: usize, options_json: impl StrArg, ) -> Result<serde_json::Value>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
pub fn to_html(&self) -> Result<String>The document as HTML.
On Document · module conversion · C nexpdf_to_html
to_json
pub fn to_json(&self) -> Result<String>The document content as JSON.
On Document · module conversion · C nexpdf_to_json
to_json_value
pub fn to_json_value(&self) -> Result<serde_json::Value>The document content as JSON.
On Document · module conversion · C nexpdf_to_json
to_xml
pub fn to_xml(&self) -> Result<String>The document content as XML.
On Document · module conversion · C nexpdf_to_xml
to_csv
pub fn to_csv(&self) -> Result<String>Tables of the document as CSV.
On Document · module conversion · C nexpdf_to_csv
to_rtf
pub fn to_rtf(&self) -> Result<String>The document as RTF.
On Document · module conversion · C nexpdf_to_rtf
to_docx
pub fn to_docx(&self) -> Result<Vec<u8>>The document as a Word (.docx) file.
On Document · module conversion · C nexpdf_to_docx
to_xlsx
pub fn to_xlsx(&self) -> Result<Vec<u8>>The document as an Excel workbook, one sheet per page.
On Document · module conversion · C nexpdf_to_xlsx
to_pptx
pub fn to_pptx(&self) -> Result<Vec<u8>>The document as a PowerPoint presentation, one slide per page.
On Document · module conversion · C nexpdf_to_pptx
to_reflow_html
pub fn to_reflow_html(&self, options_json: impl StrArg) -> Result<String>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
pub fn open_xlsx_with_clock(data: &[u8], clock_unix_seconds: f64) -> Result<Document>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 Document · module conversion · C nexpdf_open_xlsx_with_clock
open_docx_with_options_json
pub fn open_docx_with_options_json(data: &[u8], options_json: impl StrArg) -> Result<Document>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 Document · module conversion · C nexpdf_open_docx_with_options_json
Templates
template_docx_to_pdf
pub fn template_docx_to_pdf( template_bytes: &[u8], data_json: impl StrArg, options_json: impl StrArg, ) -> Result<Document>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 Document · module conversion · C nexpdf_template_docx_to_pdf
template_docx_fill
pub fn template_docx_fill(template_bytes: &[u8], data_json: impl StrArg) -> Result<Vec<u8>>Fills a Word template with JSON data and returns the new .docx bytes.
On nexpdf_sdk · module conversion · C nexpdf_template_docx_fill
template_html_to_pdf
pub fn template_html_to_pdf( html_utf8: impl StrArg, data_json: impl StrArg, options_json: impl StrArg, ) -> Result<Document>Fills an HTML template with JSON data (values HTML-escaped, {{{raw}}} not) and lays it out as a new PDF document.
On Document · module conversion · C nexpdf_template_html_to_pdf
template_fill_pdf
pub fn template_fill_pdf( &mut self, data_json: impl StrArg, options_json: impl StrArg, ) -> Result<i32>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
pub fn template_docx_fill_with( template_bytes: &[u8], data_json: impl StrArg, options_json: impl StrArg, ) -> Result<Vec<u8>>Fills a Word template with JSON data and options {"strict","locale"}, and returns the new .docx bytes.
On nexpdf_sdk · module conversion · C nexpdf_template_docx_fill_with
Office editing
xlsx_edit
pub fn xlsx_edit(data: &[u8], edits_json: impl StrArg) -> Result<Vec<u8>>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 nexpdf_sdk · module conversion · C nexpdf_xlsx_edit
xlsx_cells_json
pub fn xlsx_cells_json(data: &[u8], options_json: impl StrArg) -> Result<String>The cells of an Excel workbook as JSON: per sheet, each cell with its type, value and formula. Options {"sheet","range","recalculate"}.
On nexpdf_sdk · module conversion · C nexpdf_xlsx_cells_json
xlsx_cells_json_value
pub fn xlsx_cells_json_value(data: &[u8], options_json: impl StrArg) -> Result<serde_json::Value>The cells of an Excel workbook as JSON: per sheet, each cell with its type, value and formula. Options {"sheet","range","recalculate"}.
On nexpdf_sdk · module conversion · C nexpdf_xlsx_cells_json
docx_edit
pub fn docx_edit(data: &[u8], ops_json: impl StrArg) -> Result<Vec<u8>>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 nexpdf_sdk · module conversion · C nexpdf_docx_edit
docx_paragraphs_json
pub fn docx_paragraphs_json(data: &[u8]) -> Result<String>The paragraphs of a Word document as JSON: index, style, text and whether each is in a table.
On nexpdf_sdk · module conversion · C nexpdf_docx_paragraphs_json
docx_paragraphs_json_value
pub fn docx_paragraphs_json_value(data: &[u8]) -> Result<serde_json::Value>The paragraphs of a Word document as JSON: index, style, text and whether each is in a table.
On nexpdf_sdk · module conversion · C nexpdf_docx_paragraphs_json
Structured extraction and barcodes
extract_tables_json
pub fn extract_tables_json( &self, page_index: i32, options_json: impl StrArg, ) -> Result<String>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_tables_json_value
pub fn extract_tables_json_value( &self, page_index: i32, options_json: impl StrArg, ) -> Result<serde_json::Value>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
pub fn extract_key_values_json(&self, options_json: impl StrArg) -> Result<String>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
extract_key_values_json_value
pub fn extract_key_values_json_value( &self, options_json: impl StrArg, ) -> Result<serde_json::Value>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
pub fn extraction_prompt_json( &self, schema_json: impl StrArg, options_json: impl StrArg, ) -> Result<String>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_prompt_json_value
pub fn extraction_prompt_json_value( &self, schema_json: impl StrArg, options_json: impl StrArg, ) -> Result<serde_json::Value>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
pub fn extraction_validate_json( &self, schema_json: impl StrArg, answer_json: impl StrArg, ) -> Result<String>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
extraction_validate_json_value
pub fn extraction_validate_json_value( &self, schema_json: impl StrArg, answer_json: impl StrArg, ) -> Result<serde_json::Value>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
pub fn classify_document_json(&self, labels_json: impl StrArg) -> Result<String>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
classify_document_json_value
pub fn classify_document_json_value( &self, labels_json: impl StrArg, ) -> Result<serde_json::Value>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
pub fn read_barcodes_json(&self, page_index: i32, options_json: impl StrArg) -> Result<String>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_json_value
pub fn read_barcodes_json_value( &self, page_index: i32, options_json: impl StrArg, ) -> Result<serde_json::Value>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
pub fn read_barcodes_image_json(data: &[u8], options_json: impl StrArg) -> Result<String>Reads the barcodes of a PNG or JPEG image, with positions in pixels.
On nexpdf_sdk · module conversion · C nexpdf_read_barcodes_image_json
read_barcodes_image_json_value
pub fn read_barcodes_image_json_value( data: &[u8], options_json: impl StrArg, ) -> Result<serde_json::Value>Reads the barcodes of a PNG or JPEG image, with positions in pixels.
On nexpdf_sdk · module conversion · C nexpdf_read_barcodes_image_json
add_barcode
pub fn add_barcode( &mut self, page_index: usize, llx: f64, lly: f64, urx: f64, ury: f64, format: impl StrArg, text: impl StrArg, ) -> Result<i32>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
pub fn add_barcode_ex( &mut self, page_index: usize, llx: f64, lly: f64, urx: f64, ury: f64, format: impl StrArg, text: impl StrArg, options_json: impl StrArg, ) -> Result<i32>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
pub fn add_annotation( &mut self, page_index: usize, kind: impl StrArg, color_hex: impl StrArg, opacity: f64, contents: impl StrArg, llx: f64, lly: f64, urx: f64, ury: f64, ) -> Result<i32>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
pub fn add_ink( &mut self, page_index: usize, color_hex: impl StrArg, stroke_width: f64, opacity: f64, coords: impl StrArg, ) -> Result<i32>Adds a freehand ink annotation. coords is "x,y;x,y;..." in PDF points.
On Document · module annotations · C nexpdf_add_ink
add_line
pub fn add_line( &mut self, page_index: usize, kind: impl StrArg, color_hex: impl StrArg, opacity: f64, stroke_width: f64, x1: f64, y1: f64, x2: f64, y2: f64, ) -> Result<i32>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
pub fn annotations_json(&self, page_index: usize) -> Result<String>The annotations of a page as JSON: num, gen, kind, color, contents and the rectangle.
On Document · always available · C nexpdf_annotations_json
annotations_json_value
pub fn annotations_json_value(&self, page_index: usize) -> Result<serde_json::Value>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
pub fn remove_annotation( &mut self, page_index: usize, num: u32, generation: u16, ) -> Result<i32>Removes the annotation with object number num and generation gen from a page.
On Document · module annotations · C nexpdf_remove_annotation
move_annotation
pub fn move_annotation(&mut self, num: u32, generation: u16, dx: f64, dy: f64) -> Result<i32>Moves an annotation by (dx, dy) PDF points.
On Document · module annotations · C nexpdf_move_annotation
set_annotation_contents
pub fn set_annotation_contents( &mut self, num: u32, generation: u16, contents: impl StrArg, ) -> Result<i32>Replaces the text contents of an annotation.
On Document · module annotations · C nexpdf_set_annotation_contents
export_xfdf
pub fn export_xfdf(&self) -> Result<String>Exports every annotation as an XFDF document.
On Document · module annotations · C nexpdf_export_xfdf
import_xfdf
pub fn import_xfdf(&mut self, xfdf: impl StrArg) -> Result<i32>Imports annotations from an XFDF document.
On Document · module annotations · C nexpdf_import_xfdf
flatten_annotations
pub fn flatten_annotations(&mut self, page_index: i32) -> Result<i32>Burns annotations into the page content. A negative page index flattens every page.
On Document · module annotations · C nexpdf_flatten_annotations
add_image_stamp
pub fn add_image_stamp( &mut self, page: usize, llx: f64, lly: f64, urx: f64, ury: f64, rgba: &[u8], width: u32, height: u32, opacity: f64, ) -> Result<i32>Adds a picture stamp annotation from RGBA pixels (transparency kept). 1 on success.
On Document · module annotations · C nexpdf_add_image_stamp
add_measurement
pub fn add_measurement(&mut self, page: usize, json: impl StrArg) -> Result<String>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
pub fn measurements_json(&self) -> Result<String>The stored measurements as JSON.
On Document · always available · C nexpdf_measurements_json
measurements_json_value
pub fn measurements_json_value(&self) -> Result<serde_json::Value>The stored measurements as JSON.
On Document · always available · C nexpdf_measurements_json
add_file_attachment_annot
pub fn add_file_attachment_annot( &mut self, page_index: usize, x: f64, y: f64, name: impl StrArg, data: &[u8], mime: impl StrArg, description: impl StrArg, ) -> Result<i32>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
pub fn add_ink_signature( &mut self, page_index: usize, color_hex: impl StrArg, stroke_width: f64, strokes: impl StrArg, ) -> Result<i32>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
pub fn reply_to_annotation( &mut self, page_index: usize, num: u32, generation: u16, author: impl StrArg, text: impl StrArg, ) -> Result<i32>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
pub fn annotation_replies_json( &self, page_index: usize, num: u32, generation: u16, ) -> Result<String>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
annotation_replies_json_value
pub fn annotation_replies_json_value( &self, page_index: usize, num: u32, generation: u16, ) -> Result<serde_json::Value>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
pub fn set_annotation_state( &mut self, page_index: usize, num: u32, generation: u16, author: impl StrArg, state: impl StrArg, ) -> Result<i32>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
pub fn form_fields_json(&self) -> Result<String>The form fields as JSON: name, kind, value, page, rectangle, read_only and required.
On Document · module forms · C nexpdf_form_fields_json
form_fields_json_value
pub fn form_fields_json_value(&self) -> Result<serde_json::Value>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
pub fn fill_form_field(&mut self, name: impl StrArg, value: impl StrArg) -> Result<i32>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
pub fn set_signature_appearance( &mut self, name: impl StrArg, rgba: &[u8], width: u32, height: u32, ) -> Result<i32>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
pub fn add_form_field( &mut self, page_index: usize, kind: impl StrArg, name: impl StrArg, llx: f64, lly: f64, urx: f64, ury: f64, ) -> Result<i32>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
pub fn flatten_forms(&mut self) -> Result<i32>Burns the form fields into the page content.
On Document · module forms · C nexpdf_flatten_forms
recalculate_forms
pub fn recalculate_forms(&mut self) -> Result<i32>Runs every calculate script; returns how many fields changed.
On Document · module forms · C nexpdf_recalculate_forms
export_form_json
pub fn export_form_json(&self) -> Result<String>The field values as a JSON object.
On Document · module forms · C nexpdf_export_form_json
export_form_json_value
pub fn export_form_json_value(&self) -> Result<serde_json::Value>The field values as a JSON object.
On Document · module forms · C nexpdf_export_form_json
import_form_json
pub fn import_form_json(&mut self, json: impl StrArg) -> Result<i32>Fills fields from a JSON object of names and values.
On Document · module forms · C nexpdf_import_form_json
export_form_fdf
pub fn export_form_fdf(&self, pdf_name: impl StrArg) -> Result<Vec<u8>>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
pub fn import_form_fdf(&mut self, data: &[u8]) -> Result<i32>Fills fields from an FDF file.
On Document · module forms · C nexpdf_import_form_fdf
export_form_xfdf
pub fn export_form_xfdf(&self, pdf_name: impl StrArg) -> Result<String>The field values as XFDF.
On Document · module forms · C nexpdf_export_form_xfdf
import_form_xfdf
pub fn import_form_xfdf(&mut self, xfdf: impl StrArg) -> Result<i32>Fills fields from XFDF.
On Document · module forms · C nexpdf_import_form_xfdf
XFA forms
xfa_info_json
pub fn xfa_info_json(&self) -> Result<String>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_info_json_value
pub fn xfa_info_json_value(&self) -> Result<serde_json::Value>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
pub fn xfa_export_data(&self, format: impl StrArg) -> Result<String>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
pub fn xfa_import_data(&mut self, data: impl StrArg, format: impl StrArg) -> Result<i32>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
pub fn xfa_to_acroform(&mut self) -> Result<i32>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
pub fn xfa_flatten(&mut self) -> Result<i32>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
pub fn xfa_remove(&mut self) -> Result<i32>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
pub fn xfa_to_acroform_json(&mut self, options_json: impl StrArg) -> Result<String>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_to_acroform_json_value
pub fn xfa_to_acroform_json_value( &mut self, options_json: impl StrArg, ) -> Result<serde_json::Value>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
pub fn xfa_run_scripts_json(&mut self) -> Result<String>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
xfa_run_scripts_json_value
pub fn xfa_run_scripts_json_value(&mut self) -> Result<serde_json::Value>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
pub fn register_fallback_font(data: &[u8]) -> Result<i32>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 nexpdf_sdk · module forms · C nexpdf_register_fallback_font
Real-time collaboration
sync_export_json
pub fn sync_export_json(&mut self, since_version: u64) -> Result<String>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_json_value
pub fn sync_export_json_value(&mut self, since_version: u64) -> Result<serde_json::Value>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
pub fn sync_export_local_json(&mut self, since_version: u64) -> Result<String>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_export_local_json_value
pub fn sync_export_local_json_value( &mut self, since_version: u64, ) -> Result<serde_json::Value>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
pub fn sync_apply_json(&mut self, changes_json: impl StrArg) -> Result<String>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_apply_json_value
pub fn sync_apply_json_value( &mut self, changes_json: impl StrArg, ) -> Result<serde_json::Value>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
pub fn sync_snapshot_json(&mut self) -> Result<String>NexPDF Sync: every record with its version, base records and tombstones included.
On Document · module annotations · C nexpdf_sync_snapshot_json
sync_snapshot_json_value
pub fn sync_snapshot_json_value(&mut self) -> Result<serde_json::Value>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
pub fn sync_set_client_id(&mut self, client_id: impl StrArg) -> Result<i32>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
pub fn rotate_page(&mut self, page_index: usize, degrees: i32) -> Result<i32>Rotates a page by a multiple of 90 degrees.
On Document · module editor · C nexpdf_rotate_page
delete_page
pub fn delete_page(&mut self, page_index: usize) -> Result<i32>Deletes a page.
On Document · module editor · C nexpdf_delete_page
duplicate_page
pub fn duplicate_page(&mut self, page_index: usize) -> Result<i32>Inserts a copy of a page after it.
On Document · module editor · C nexpdf_duplicate_page
add_blank_page
pub fn add_blank_page(&mut self) -> Result<i32>Appends a blank page.
On Document · module editor · C nexpdf_add_blank_page
reverse_pages
pub fn reverse_pages(&mut self) -> Result<i32>Reverses the page order.
On Document · module editor · C nexpdf_reverse_pages
move_page
pub fn move_page(&mut self, from: usize, to: usize) -> Result<i32>Moves the page at from to index to.
On Document · module editor · C nexpdf_move_page
crop_page
pub fn crop_page( &mut self, page_index: usize, llx: f64, lly: f64, urx: f64, ury: f64, ) -> Result<i32>Sets the crop box of a page (PDF points).
On Document · module editor · C nexpdf_crop_page
extract_pages
pub fn extract_pages(&self, indices: &[u32]) -> Result<Document>A new document made of the given pages (split).
On Document · module editor · C nexpdf_extract_pages
append_document
pub fn append_document(&mut self, other: &Document) -> Result<i32>Appends the pages of another document (merge).
On Document · module editor · C nexpdf_append_document
insert_image_pages
pub fn insert_image_pages(&mut self, index: usize, data: &[u8]) -> Result<i32>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
pub fn set_page_background( &mut self, options_json: impl StrArg, rgb: &[u8], width: u32, height: u32, ) -> Result<i32>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
pub fn remove_page_background(&mut self, pages_json: impl StrArg) -> Result<i32>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
pub fn page_content_json(&self, page: usize) -> Result<String>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
page_content_json_value
pub fn page_content_json_value(&self, page: usize) -> Result<serde_json::Value>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
pub fn edit_text( &mut self, page: usize, id: impl StrArg, change_json: impl StrArg, ) -> Result<i32>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
pub fn add_page_text(&mut self, page: usize, json: impl StrArg) -> Result<i32>Adds editable page text: {text, x, y (baseline), size, color, family, bold, italic}.
On Document · module editor · C nexpdf_add_page_text
delete_content
pub fn delete_content(&mut self, page: usize, id: impl StrArg) -> Result<i32>Deletes a text line or an image of the page content.
On Document · module editor · C nexpdf_delete_content
transform_image
pub fn transform_image( &mut self, page: usize, id: impl StrArg, llx: f64, lly: f64, urx: f64, ury: f64, ) -> Result<i32>Moves or resizes an image to a rectangle (PDF points).
On Document · module editor · C nexpdf_transform_image
replace_image
pub fn replace_image( &mut self, page: usize, id: impl StrArg, rgb: &[u8], width: u32, height: u32, ) -> Result<i32>Replaces an image with RGB pixels (width x height x 3 bytes).
On Document · module editor · C nexpdf_replace_image
edit_text_block
pub fn edit_text_block( &mut self, page_index: usize, text: impl StrArg, color_hex: impl StrArg, font_size: f64, bold: i32, italic: i32, replace_existing: i32, llx: f64, lly: f64, urx: f64, ury: f64, ) -> Result<i32>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
pub fn metadata_json(&self) -> Result<String>The document information (title, author, subject, keywords, ...) as JSON.
On Document · always available · C nexpdf_metadata_json
metadata_json_value
pub fn metadata_json_value(&self) -> Result<serde_json::Value>The document information (title, author, subject, keywords, ...) as JSON.
On Document · always available · C nexpdf_metadata_json
set_metadata
pub fn set_metadata( &mut self, title: impl StrArg, author: impl StrArg, subject: impl StrArg, keywords: impl StrArg, ) -> Result<i32>Sets the title, author, subject and keywords. Omitted (null) values keep the current one.
On Document · module editor · C nexpdf_set_metadata
outlines_json
pub fn outlines_json(&self) -> Result<String>The bookmarks as JSON: [{"title","page","children":[...]}].
On Document · always available · C nexpdf_outlines_json
outlines_json_value
pub fn outlines_json_value(&self) -> Result<serde_json::Value>The bookmarks as JSON: [{"title","page","children":[...]}].
On Document · always available · C nexpdf_outlines_json
set_outlines_json
pub fn set_outlines_json(&mut self, json: impl StrArg) -> Result<i32>Replaces the bookmarks with a JSON tree in the same shape.
On Document · module editor · C nexpdf_set_outlines_json
page_labels_json
pub fn page_labels_json(&self) -> Result<String>Page labels: {"labels":["i","ii","1"],"ranges":[{"start":0,"style":"roman","prefix":"","first":1}]}.
On Document · always available · C nexpdf_page_labels_json
page_labels_json_value
pub fn page_labels_json_value(&self) -> Result<serde_json::Value>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
pub fn set_page_labels_json(&mut self, json: impl StrArg) -> Result<i32>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
pub fn layers_json(&self) -> Result<String>The optional content groups (layers): [{"num","gen","name","visible","printable"}].
On Document · always available · C nexpdf_layers_json
layers_json_value
pub fn layers_json_value(&self) -> Result<serde_json::Value>The optional content groups (layers): [{"num","gen","name","visible","printable"}].
On Document · always available · C nexpdf_layers_json
set_layer_visible
pub fn set_layer_visible(&mut self, num: u32, generation: u16, visible: i32) -> Result<i32>Shows or hides a layer.
On Document · always available · C nexpdf_set_layer_visible
attachments_json
pub fn attachments_json(&self) -> Result<String>The embedded files: [{"name","description","mime","size","page"}]; page is null for document-level files.
On Document · always available · C nexpdf_attachments_json
attachments_json_value
pub fn attachments_json_value(&self) -> Result<serde_json::Value>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
pub fn attachment_data(&self, name: impl StrArg) -> Result<Vec<u8>>The bytes of an embedded file.
On Document · always available · C nexpdf_attachment_data
add_attachment
pub fn add_attachment( &mut self, name: impl StrArg, data: &[u8], mime: impl StrArg, description: impl StrArg, ) -> Result<i32>Embeds a file at document level.
On Document · module editor · C nexpdf_add_attachment
remove_attachment
pub fn remove_attachment(&mut self, name: impl StrArg) -> Result<i32>Removes an embedded file.
On Document · module editor · C nexpdf_remove_attachment
Encryption, watermarks and stamping
encrypt_aes256
pub fn encrypt_aes256(&mut self, user_pw: impl StrArg, owner_pw: impl StrArg) -> Result<i32>Encrypts with AES-256 using a user (open) password and an owner password.
On Document · module security · C nexpdf_encrypt_aes256
encrypt_with_permissions
pub fn encrypt_with_permissions( &mut self, user_pw: impl StrArg, owner_pw: impl StrArg, permissions: u32, ) -> Result<i32>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
pub fn security_json(&self) -> Result<String>The encryption state: {"encrypted","revision","owner","print","modify","copy","annotate","fill_forms","assemble"}.
On Document · always available · C nexpdf_security_json
security_json_value
pub fn security_json_value(&self) -> Result<serde_json::Value>The encryption state: {"encrypted","revision","owner","print","modify","copy","annotate","fill_forms","assemble"}.
On Document · always available · C nexpdf_security_json
remove_password
pub fn remove_password(&mut self, password: impl StrArg) -> Result<i32>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
pub fn add_watermark(&mut self, text: impl StrArg) -> Result<i32>Stamps a text watermark on every page.
On Document · module security · C nexpdf_add_watermark
remove_watermarks
pub fn remove_watermarks(&mut self) -> Result<i32>Removes the watermarks NexPDF added.
On Document · module security · C nexpdf_remove_watermarks
add_header_footer
pub fn add_header_footer( &mut self, header: impl StrArg, footer: impl StrArg, font_size: f64, ) -> Result<i32>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
pub fn add_bates(&mut self, prefix: impl StrArg, start: u64, digits: u32) -> Result<i32>Adds Bates numbering: prefix, first number and number of digits.
On Document · module security · C nexpdf_add_bates
Redaction
apply_redaction
pub fn apply_redaction( &mut self, page_index: usize, llx: f64, lly: f64, urx: f64, ury: f64, fill_white: i32, ) -> Result<i32>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
pub fn redact_matches( &mut self, query: impl StrArg, mode: i32, fill_white: i32, ) -> Result<i32>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
pub fn sign_pades( &self, signer: impl StrArg, reason: impl StrArg, location: impl StrArg, ) -> Result<Vec<u8>>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
pub fn sign_pkcs12( &self, p12: &[u8], password: impl StrArg, options_json: impl StrArg, ) -> Result<Vec<u8>>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
pub fn pkcs12_info_json(data: &[u8], password: impl StrArg) -> Result<String>The certificate summary of a PKCS#12 file; fails with "incorrect password" on a wrong password.
On nexpdf_sdk · module signatures · C nexpdf_pkcs12_info_json
pkcs12_info_json_value
pub fn pkcs12_info_json_value(data: &[u8], password: impl StrArg) -> Result<serde_json::Value>The certificate summary of a PKCS#12 file; fails with "incorrect password" on a wrong password.
On nexpdf_sdk · module signatures · C nexpdf_pkcs12_info_json
prepare_external_signature
pub fn prepare_external_signature( &self, cert: &[u8], options_json: impl StrArg, ) -> Result<Vec<u8>>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
pub fn external_signature_data(prepared: &[u8], cert: &[u8]) -> Result<Vec<u8>>External signing, step 2: the bytes to sign (DER signed attributes; sign their SHA-256 on devices that take a digest).
On nexpdf_sdk · module signatures · C nexpdf_external_signature_data
complete_external_signature
pub fn complete_external_signature( prepared: &[u8], cert: &[u8], signature: &[u8], algorithm: i32, options_json: impl StrArg, ) -> Result<Vec<u8>>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 nexpdf_sdk · module signatures · C nexpdf_complete_external_signature
verify_signatures_json
pub fn verify_signatures_json(data: &[u8]) -> Result<String>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 nexpdf_sdk · always available · C nexpdf_verify_signatures_json
verify_signatures_json_value
pub fn verify_signatures_json_value(data: &[u8]) -> Result<serde_json::Value>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 nexpdf_sdk · always available · C nexpdf_verify_signatures_json
verify_signatures_with_roots_json
pub fn verify_signatures_with_roots_json(data: &[u8], roots_pem: impl StrArg) -> Result<String>Verifies the signatures treating the PEM certificates in roots_pem as trust anchors.
On nexpdf_sdk · module signatures · C nexpdf_verify_signatures_with_roots_json
verify_signatures_with_roots_json_value
pub fn verify_signatures_with_roots_json_value( data: &[u8], roots_pem: impl StrArg, ) -> Result<serde_json::Value>Verifies the signatures treating the PEM certificates in roots_pem as trust anchors.
On nexpdf_sdk · module signatures · C nexpdf_verify_signatures_with_roots_json
add_ltv
pub fn add_ltv(data: &[u8]) -> Result<Vec<u8>>Adds long-term validation data (DSS with OCSP responses and CRLs) to a signed file.
On nexpdf_sdk · module signatures · C nexpdf_add_ltv
add_document_timestamp
pub fn add_document_timestamp(&self, options_json: impl StrArg) -> Result<Vec<u8>>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
pub fn add_document_timestamp_bytes(data: &[u8], options_json: impl StrArg) -> Result<Vec<u8>>Adds a document timestamp to the bytes of a PDF file (for example straight from signing). Same options. Returns the new file.
On nexpdf_sdk · module signatures · C nexpdf_add_document_timestamp_bytes
prepare_document_timestamp
pub fn prepare_document_timestamp(&self, options_json: impl StrArg) -> Result<Vec<u8>>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
pub fn document_timestamp_request(prepared: &[u8], hash: impl StrArg) -> Result<Vec<u8>>Document timestamp, step 2: the DER TimeStampReq to send to the TSA as application/timestamp-query (hash SHA-256 by default).
On nexpdf_sdk · module signatures · C nexpdf_document_timestamp_request
complete_document_timestamp
pub fn complete_document_timestamp(prepared: &[u8], token: &[u8]) -> Result<Vec<u8>>Document timestamp, step 3: the timestamped PDF, from the prepared file and the TSA token (TimeStampResp or TimeStampToken).
On nexpdf_sdk · module signatures · C nexpdf_complete_document_timestamp
signature_timestamp_request
pub fn signature_timestamp_request(data: &[u8], hash: impl StrArg) -> Result<Vec<u8>>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 nexpdf_sdk · module signatures · C nexpdf_signature_timestamp_request
add_signature_timestamp
pub fn add_signature_timestamp(data: &[u8], token: &[u8]) -> Result<Vec<u8>>B-T in steps: stores the TSA answer (TimeStampResp or TimeStampToken) in the last signature, signed bytes unchanged, and returns the PDF.
On nexpdf_sdk · module signatures · C nexpdf_add_signature_timestamp
ltv_requests_json
pub fn ltv_requests_json(data: &[u8], responses_json: impl StrArg) -> Result<String>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 nexpdf_sdk · module signatures · C nexpdf_ltv_requests_json
ltv_requests_json_value
pub fn ltv_requests_json_value( data: &[u8], responses_json: impl StrArg, ) -> Result<serde_json::Value>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 nexpdf_sdk · module signatures · C nexpdf_ltv_requests_json
add_ltv_with_responses
pub fn add_ltv_with_responses(data: &[u8], responses_json: impl StrArg) -> Result<Vec<u8>>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 nexpdf_sdk · module signatures · C nexpdf_add_ltv_with_responses
validate_lta_json
pub fn validate_lta_json(data: &[u8], trust_roots_pem: impl StrArg) -> Result<String>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 nexpdf_sdk · module signatures · C nexpdf_validate_lta_json
validate_lta_json_value
pub fn validate_lta_json_value( data: &[u8], trust_roots_pem: impl StrArg, ) -> Result<serde_json::Value>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 nexpdf_sdk · module signatures · C nexpdf_validate_lta_json
PDF/A, PDF/X and PDF/UA
convert_pdfa
pub fn convert_pdfa(&mut self) -> Result<i32>Converts the document to PDF/A (ISO 19005) for archiving.
On Document · module standards · C nexpdf_convert_pdfa
convert_pdfx
pub fn convert_pdfx(&mut self) -> Result<i32>Converts the document to PDF/X for print exchange.
On Document · module standards · C nexpdf_convert_pdfx
auto_tag
pub fn auto_tag(&mut self, lang: impl StrArg, force: i32) -> Result<String>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
pub fn validate_pdfa_json(&self, level: impl StrArg) -> Result<String>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_pdfa_json_value
pub fn validate_pdfa_json_value(&self, level: impl StrArg) -> Result<serde_json::Value>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
pub fn validate_pdfua_json(&self) -> Result<String>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
validate_pdfua_json_value
pub fn validate_pdfua_json_value(&self) -> Result<serde_json::Value>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
pub fn convert_pdfa_level(&mut self, level: impl StrArg) -> Result<i32>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
pub fn convert_pdfa_json( &mut self, level: impl StrArg, flatten_dpi: f64, substitute_fonts: i32, ) -> Result<String>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_pdfa_json_value
pub fn convert_pdfa_json_value( &mut self, level: impl StrArg, flatten_dpi: f64, substitute_fonts: i32, ) -> Result<serde_json::Value>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
pub fn convert_pdfua_json(&mut self, part: i32, lang: impl StrArg) -> Result<String>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
convert_pdfua_json_value
pub fn convert_pdfua_json_value( &mut self, part: i32, lang: impl StrArg, ) -> Result<serde_json::Value>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
pub fn validate_pdfua_part_json(&self, part: i32) -> Result<String>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
validate_pdfua_part_json_value
pub fn validate_pdfua_part_json_value(&self, part: i32) -> Result<serde_json::Value>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
pub fn register_substitute_font(data: &[u8]) -> Result<String>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 nexpdf_sdk · module standards · C nexpdf_register_substitute_font
OCR
ocr
pub fn ocr(&mut self, options_json: impl StrArg) -> Result<String>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
pub fn ocr_load_model( options_json: impl StrArg, model: &[u8], dictionary: impl StrArg, ) -> Result<i32>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 nexpdf_sdk · module ocr · C nexpdf_ocr_load_model
ocr_models_json
pub fn ocr_models_json() -> Result<String>The loaded OCR models: kind, name, languages, symbols, size.
On nexpdf_sdk · module ocr · C nexpdf_ocr_models_json
ocr_models_json_value
pub fn ocr_models_json_value() -> Result<serde_json::Value>The loaded OCR models: kind, name, languages, symbols, size.
On nexpdf_sdk · module ocr · C nexpdf_ocr_models_json
ocr_unload_models
pub fn ocr_unload_models(languages: impl StrArg) -> Result<i32>Unloads the OCR models of the given languages (all when empty). Returns the number removed.
On nexpdf_sdk · module ocr · C nexpdf_ocr_unload_models
Compare, optimise and memory
compare_json
pub fn compare_json(&self, b: &Document, dpi: f64) -> Result<String>Compares two documents (text and visual differences per page) at the given resolution, as JSON.
On Document · always available · C nexpdf_compare_json
compare_json_value
pub fn compare_json_value(&self, b: &Document, dpi: f64) -> Result<serde_json::Value>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
pub fn compare_overlay_png( &self, b: &Document, page_index: usize, dpi: f64, ) -> Result<Vec<u8>>A PNG overlay of the visual differences of one page of two documents.
On Document · always available · C nexpdf_compare_overlay_png
optimize
pub fn optimize(&mut self) -> Result<String>Optimises the document (removes unused objects, recompresses streams); returns a JSON report.
On Document · module editor · C nexpdf_optimize
subset_fonts
pub fn subset_fonts(&mut self) -> Result<String>Subsets the embedded fonts to the glyphs the document uses; returns a JSON report.
On Document · module editor · C nexpdf_subset_fonts
trim_memory
pub fn trim_memory(&mut self) -> usizeDrops cached data of the document; returns the bytes freed.
On Document · always available · C nexpdf_trim_memory
memory_usage_bytes
pub fn memory_usage_bytes(&self) -> usizeApproximate memory used by the document, in bytes.
On Document · always available · C nexpdf_memory_usage_bytes
compare_text_json
pub fn compare_text_json(&self, b: &Document, options_json: impl StrArg) -> Result<String>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_text_json_value
pub fn compare_text_json_value( &self, b: &Document, options_json: impl StrArg, ) -> Result<serde_json::Value>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
pub fn compare_annotate(&self, b: &Document, options_json: impl StrArg) -> Result<Vec<u8>>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
pub fn set_annotation_flags( &mut self, num: u32, generation: u16, flags_json: impl StrArg, ) -> Result<i32>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
pub fn set_annotation_style( &mut self, num: u32, generation: u16, style_json: impl StrArg, ) -> Result<i32>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