API reference
Every class, method and function of the NexPDF Android SDK, grouped by feature. Generated from NexPDF 1.1.0.
Generated from NexPDF 1.1.0
This page is generated from the sources of com.nexdevit:nexpdf-android. It lists 220 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
initialize
public static int initialize(Context context)
public static int initialize(Context context, String keyOrXml)Activates the key from the manifest meta-data, else from assets/nexpdf_license.xml.
On NexPdfLicense (static)
status
public static String status()Current state as JSON: state (unlicensed|trial|licensed), licensee, modules, days_left…
On NexPdfLicense (static)
openBytes
public static NexPdfDocument openBytes(byte[] bytes)
public static NexPdfDocument openBytes(byte[] bytes, String password)Opens PDF bytes, or JPEG / PNG / TIFF pictures (one page each). Word / Excel / PowerPoint files and EPUB / FictionBook / XPS books and CBZ comics are converted (module: conversion).
On NexPdfDocument
isPasswordError
public static boolean isPasswordError(Throwable e)Whether an exception from #openBytes means the password is missing or wrong.
On NexPdfDocument
openEbook
public static NexPdfDocument openEbook(byte[] bytes)EPUB, FictionBook (.fb2 / .fb2.zip), XPS / OpenXPS or CBZ comic bytes to a new PDF (module: conversion).
On NexPdfDocument
openImage
public static NexPdfDocument openImage(byte[] bytes)JPEG / PNG / TIFF pictures to a new PDF, one page per picture.
On NexPdfDocument
openOffice
public static NexPdfDocument openOffice(byte[] bytes)Converts DOCX / XLSX / PPTX bytes to a new PDF.
On NexPdfDocument
fromHtml
public static NexPdfDocument fromHtml(String html)Lays out HTML as a new PDF.
On NexPdfDocument
handle
public long handle()The native handle, for NexPdfJni calls. @Override
On NexPdfDocument
pageCount
public int pageCount()On NexPdfDocument
pageWidth
public double pageWidth(int pageIndex)Displayed page width in points: the crop box (clipped to the media box), after /Rotate and /UserUnit.
On NexPdfDocument
pageHeight
public double pageHeight(int pageIndex)Displayed page height in points: the crop box (clipped to the media box), after /Rotate and /UserUnit.
On NexPdfDocument
pageView
public PageView pageView(int pageIndex)How the page is displayed (crop box, rotation, user unit) and the PDF <-> display transform. Use it for every screen/PDF coordinate conversion. Never null: falls back to an unrotated page of #pageWidth x #pageHeight at the origin.
On NexPdfDocument
renderPagePng
public byte[] renderPagePng(int pageIndex, double dpi)On NexPdfDocument
pageText
public String pageText(int pageIndex)On NexPdfDocument
toMarkdown
public String toMarkdown()On NexPdfDocument
toJson
public String toJson()On NexPdfDocument
toDocx
public byte[] toDocx()On NexPdfDocument
searchJson
public String searchJson(String query)Finds query; a JSON array of {page, context, llx, lly, urx, ury}: the 0-based page, the surrounding text and the match rectangle in PDF points (origin bottom-left).
On NexPdfDocument
saveBytes
public byte[] saveBytes()The document, with all changes, as PDF bytes.
On NexPdfDocument
saveLinearized
public byte[] saveLinearized()Linearized ("Fast Web View") PDF bytes: the first page shows before the download ends.
On NexPdfDocument
pageLabelsJson
public String pageLabelsJson(){"labels":["i","ii","1"],"ranges":[{"start":0,"style":"roman","prefix":"","first":1]}}.
On NexPdfDocument
setPageLabelsJson
public boolean setPageLabelsJson(String rangesJson)Sets the page label ranges ([] removes them; module: editor).
On NexPdfDocument
trimMemory
public long trimMemory()Compacts internal buffers; returns the approximate number of bytes reclaimed.
On NexPdfDocument
prepareExternalSignature
public byte[] prepareExternalSignature(byte[] cert, String optionsJson)External signing, step 1 of 3: this document with an empty signature, to pass to #externalSignatureData and then #completeExternalSignature. cert is the signer certificate in PEM or DER, optionally followed by its chain.
On NexPdfDocument
externalSignatureData
public static byte[] externalSignatureData(byte[] prepared, byte[] cert)External signing, step 2: the bytes the HSM / card / KMS signs (DER signed attributes).
On NexPdfDocument
completeExternalSignature
public static byte[] completeExternalSignature(byte[] prepared, byte[] cert, byte[] signature, int algorithm, String optionsJson)External signing, step 3: the signed PDF. algorithm 0 = RSA PKCS#1 v1.5 SHA-256, 1 = ECDSA SHA-256 (DER or raw r||s). Options {"tsa_url":"…","ltv":true} or null.
On NexPdfDocument
fromDocxTemplate
public static NexPdfDocument fromDocxTemplate(byte[] template, String dataJson, String optionsJson)Fills a Word template with dataJson and converts it to PDF. Throws when it fails (e.g. a strict missing field).
On NexPdfDocument
fromHtmlTemplate
public static NexPdfDocument fromHtmlTemplate(String html, String dataJson, String optionsJson)Fills an HTML template with dataJson and lays it out as a new PDF.
On NexPdfDocument
fillDocxTemplate
public static byte[] fillDocxTemplate(byte[] template, String dataJson)Fills a Word template; the new .docx (empty on failure, see NexPdfJni#lastError()).
On NexPdfDocument
fillTemplate
public int fillTemplate(String dataJson, String optionsJson)Fills this PDF's form fields and text placeholders; the number filled, or -1.
On NexPdfDocument
addDocumentTimestamp
public byte[] addDocumentTimestamp(String optionsJson)This document with a PAdES document time-stamp from tsa_url (module: signatures).
On NexPdfDocument
prepareDocumentTimestamp
public byte[] prepareDocumentTimestamp(String optionsJson)Own TSA / HSM, step 1 (then NexPdfJni#documentTimestampRequest, NexPdfJni#completeDocumentTimestamp).
On NexPdfDocument
replyToAnnotation
public int replyToAnnotation(int pageIndex, int num, int gen, String author, String text)Replies to annotation num / gen; the reply's object number, or 0.
On NexPdfDocument
annotationRepliesJson
public String annotationRepliesJson(int pageIndex, int num, int gen)The thread under an annotation, oldest first, as JSON.
On NexPdfDocument
setAnnotationState
public int setAnnotationState(int pageIndex, int num, int gen, String author, String state)Sets a reviewer state ("Accepted", "Rejected", "Completed", "Marked", …); the state reply's number, or 0.
On NexPdfDocument
extractTablesJson
public String extractTablesJson(int pageIndex, String optionsJson)Tables of pageIndex (< 0 = every page) as JSON.
On NexPdfDocument
extractKeyValuesJson
public String extractKeyValuesJson(String optionsJson)On NexPdfDocument
extractionPromptJson
public String extractionPromptJson(String schemaJson, String optionsJson)On NexPdfDocument
extractionValidateJson
public String extractionValidateJson(String schemaJson, String answerJson)Validates a language model's answer against the schema, grounded on this document's pages.
On NexPdfDocument
classifyJson
public String classifyJson(String labelsJson)On NexPdfDocument
xfaInfoJson
public String xfaInfoJson()On NexPdfDocument
xfaExportData
public String xfaExportData(String format)"xml" (null) or "json"; "" when there is no XFA.
On NexPdfDocument
xfaImportData
public int xfaImportData(String data, String format)On NexPdfDocument
xfaToAcroform
public int xfaToAcroform()On NexPdfDocument
xfaFlatten
public int xfaFlatten()On NexPdfDocument
xfaRemove
public int xfaRemove()On NexPdfDocument
compareTextJson
public String compareTextJson(NexPdfDocument newer, String optionsJson)Word-level changes from this (old) document to newer, as JSON (module: viewer).
On NexPdfDocument
compareAnnotate
public byte[] compareAnnotate(NexPdfDocument newer, String optionsJson)The comparison as a PDF with highlight annotations (open it with #openBytes).
On NexPdfDocument
readBarcodesJson
public String readBarcodesJson(int pageIndex, String optionsJson)Barcodes on pageIndex (< 0 = every page) as JSON, rectangles in PDF points.
On NexPdfDocument
readBarcodesImageJson
public static String readBarcodesImageJson(byte[] image, String optionsJson)Barcodes in a PNG or JPEG picture as JSON, rectangles in pixels.
On NexPdfDocument
addBarcode
public boolean addBarcode(int pageIndex, double llx, double lly, double urx, double ury, String format, String text)Draws text as a vector barcode into the rectangle (PDF points).
On NexPdfDocument
validatePdfaJson
public String validatePdfaJson(String level)On NexPdfDocument
validatePdfuaJson
public String validatePdfuaJson()On NexPdfDocument
convertPdfaLevel
public boolean convertPdfaLevel(String level)Converts to a PDF/A level; false when clauses still fail (NexPdfJni#lastError() lists them).
On NexPdfDocument
isClosed
public boolean isClosed()On NexPdfDocument
close
public void close()On NexPdfDocument
setEventListener
public static void setEventListener(EventListener l)Receives the events of every reader (main thread). Pass null to stop.
On NexPdfReaderActivity (static)
closeCurrent
public static void closeCurrent()Closes the reader that is on screen, if any (used by the React Native and Flutter bridges).
On NexPdfReaderActivity (static)
intent
public static Intent intent(android.content.Context ctx, Uri document, String configJson)An intent that opens document (content: or file: URI, may be null) with configJson.
On NexPdfReaderActivity (static)
Library and licensing
version
public static native String version();The engine version.
On NexPdfJni (static) · always available · C nexpdf_version
licenseActivate
public static native int licenseActivate(String keyOrXml, String platform, String appId);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 NexPdfJni (static) · always available · C nexpdf_license_activate
licenseStatusJson
public static native String licenseStatusJson();The active license as JSON: state (unlicensed, trial or licensed), licensee, id, tier, modules, expires_at, days_left and watermark.
On NexPdfJni (static) · always available · C nexpdf_license_status_json
lastError
public static native String lastError();Why the last call on this thread failed, or nothing.
On NexPdfJni (static) · always available · C nexpdf_last_error
clearError
public static native void clearError();Clears the last error of this thread.
On NexPdfJni (static) · always available · C nexpdf_clear_error
invoke
public static native String invoke(String requestJson);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 NexPdfJni (static) · always available · C nexpdf_invoke
registerStandardFont
public static native boolean registerStandardFont(byte[] fontBytes);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 NexPdfJni (static) · always available · C nexpdf_register_standard_font
hasBundledFonts
public static native boolean hasBundledFonts();1 when the Liberation fonts are compiled in, 0 in the lighter builds.
On NexPdfJni (static) · always available · C nexpdf_has_bundled_fonts
free
public static native void free(long handle);Frees a document.
On NexPdfJni (static) · always available · C nexpdf_free
Opening and saving
openBytes
public static native long openBytes(byte[] pdfBytes);Opens a PDF from bytes. JPEG, PNG and TIFF pictures are also accepted (one page per picture).
On NexPdfJni (static) · always available · C nexpdf_open_bytes
openBytesWithPassword
public static native long openBytesWithPassword(byte[] pdfBytes, String password);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 NexPdfJni (static) · always available · C nexpdf_open_bytes_with_password
fromHtml
public static native long fromHtml(String html);Lays out HTML as a new PDF document.
On NexPdfJni (static) · module conversion · C nexpdf_from_html
openOffice
public static native long openOffice(byte[] data);Converts Word, Excel or PowerPoint bytes (format detected) to a new PDF document.
On NexPdfJni (static) · module conversion · C nexpdf_open_office
openEbook
public static native long openEbook(byte[] data);Converts EPUB, FictionBook (.fb2, .fb2.zip), XPS/OpenXPS or a CBZ comic archive to a new PDF document.
On NexPdfJni (static) · module conversion · C nexpdf_open_ebook
openImage
public static native long openImage(byte[] data);Converts JPEG, PNG or TIFF bytes to a new PDF, one page per picture.
On NexPdfJni (static) · always available · C nexpdf_open_image
saveBytes
public static native byte[] saveBytes(long handle);The document, with every change, as PDF bytes (full rewrite).
On NexPdfJni (static) · always available · C nexpdf_save_bytes
saveLinearized
public static native byte[] saveLinearized(long handle);A linearized ("Fast Web View") PDF: the first page shows before the download ends.
On NexPdfJni (static) · always available · C nexpdf_save_linearized
Pages and rendering
pageCount
public static native int pageCount(long handle);Number of pages.
On NexPdfJni (static) · always available · C nexpdf_page_count
pageWidth
public static native double pageWidth(long handle, int pageIndex);Displayed page width in points (crop box, rotation and /UserUnit applied).
On NexPdfJni (static) · always available · C nexpdf_page_width
pageHeight
public static native double pageHeight(long handle, int pageIndex);Displayed page height in points (crop box, rotation and /UserUnit applied).
On NexPdfJni (static) · always available · C nexpdf_page_height
pageViewJson
public static native String pageViewJson(long handle, int pageIndex);How the page is displayed: width, height, rotation, user_unit, crop and the PDF-to-display matrix to_display.
On NexPdfJni (static) · always available · C nexpdf_page_view_json
renderPagePng
public static native byte[] renderPagePng(long handle, int pageIndex, double dpi);Renders a page to PNG at the given resolution (dots per inch). Unlicensed and trial renders carry a watermark.
On NexPdfJni (static) · always available · C nexpdf_render_page_png
renderThumbPng
public static native byte[] renderThumbPng(long handle, int pageIndex, int maxDim);Renders a thumbnail PNG whose longer side is at most max_dim pixels.
On NexPdfJni (static) · always available · C nexpdf_render_thumb_png
setOverprint
public static native boolean setOverprint(long handle, int mode);Overprint simulation for later renders: 0 = PDF/X documents only (default), 1 = always, 2 = never.
On NexPdfJni (static) · always available · C nexpdf_set_overprint
Text, search and assistant
extractPageText
public static native String extractPageText(long handle, int pageIndex);The text of a page in reading order.
On NexPdfJni (static) · always available · C nexpdf_extract_page_text
extractMarkdown
public static native String extractMarkdown(long handle);The whole document as Markdown (headings, lists, tables).
On NexPdfJni (static) · always available · C nexpdf_extract_markdown
searchJson
public static native String searchJson(long handle, String query);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 NexPdfJni (static) · always available · C nexpdf_search_json
pageBlocksJson
public static native String pageBlocksJson(long handle, int pageIndex);The text blocks of a page as JSON: text, font size and the rectangle llx, lly, urx, ury.
On NexPdfJni (static) · always available · C nexpdf_page_blocks_json
askDocument
public static native String askDocument(long handle, String question, int k, int maxChars);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 NexPdfJni (static) · always available · C nexpdf_ask_document
Conversion
toHtml
public static native String toHtml(long handle);The document as HTML.
On NexPdfJni (static) · module conversion · C nexpdf_to_html
toJson
public static native String toJson(long handle);The document content as JSON.
On NexPdfJni (static) · module conversion · C nexpdf_to_json
toXml
public static native String toXml(long handle);The document content as XML.
On NexPdfJni (static) · module conversion · C nexpdf_to_xml
toCsv
public static native String toCsv(long handle);Tables of the document as CSV.
On NexPdfJni (static) · module conversion · C nexpdf_to_csv
toRtf
public static native String toRtf(long handle);The document as RTF.
On NexPdfJni (static) · module conversion · C nexpdf_to_rtf
toDocx
public static native byte[] toDocx(long handle);The document as a Word (.docx) file.
On NexPdfJni (static) · module conversion · C nexpdf_to_docx
toXlsx
public static native byte[] toXlsx(long handle);The document as an Excel workbook, one sheet per page.
On NexPdfJni (static) · module conversion · C nexpdf_to_xlsx
toPptx
public static native byte[] toPptx(long handle);The document as a PowerPoint presentation, one slide per page.
On NexPdfJni (static) · module conversion · C nexpdf_to_pptx
reflowHtml
public static native String reflowHtml(long handle, String optionsJson);The text as responsive HTML for small screens. Options (may be omitted): {"pages":[0],"images":true,"full_page":true,"title":"..."}.
On NexPdfJni (static) · module conversion · C nexpdf_to_reflow_html
Templates
templateDocxToPdf
public static native long templateDocxToPdf(byte[] template, String dataJson, String optionsJson);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 NexPdfJni (static) · module conversion · C nexpdf_template_docx_to_pdf
templateDocxFill
public static native byte[] templateDocxFill(byte[] template, String dataJson);Fills a Word template with JSON data and returns the new .docx bytes.
On NexPdfJni (static) · module conversion · C nexpdf_template_docx_fill
templateHtmlToPdf
public static native long templateHtmlToPdf(String html, String dataJson, String optionsJson);Fills an HTML template with JSON data (values HTML-escaped, {{{raw}}} not) and lays it out as a new PDF document.
On NexPdfJni (static) · module conversion · C nexpdf_template_html_to_pdf
templateFillPdf
public static native int templateFillPdf(long handle, String dataJson, String optionsJson);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 NexPdfJni (static) · module conversion · C nexpdf_template_fill_pdf
Structured extraction and barcodes
extractTablesJson
public static native String extractTablesJson(long handle, int pageIndex, String optionsJson);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 NexPdfJni (static) · module conversion · C nexpdf_extract_tables_json
extractKeyValuesJson
public static native String extractKeyValuesJson(long handle, String optionsJson);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 NexPdfJni (static) · module conversion · C nexpdf_extract_key_values_json
extractionPromptJson
public static native String extractionPromptJson(long handle, String schemaJson, String optionsJson);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 NexPdfJni (static) · module conversion · C nexpdf_extraction_prompt_json
extractionValidateJson
public static native String extractionValidateJson(long handle, String schemaJson, String answerJson);Validates and coerces a model answer against the schema and grounds each value on the pages: valid, value, errors, warnings, fields.
On NexPdfJni (static) · module conversion · C nexpdf_extraction_validate_json
classifyDocumentJson
public static native String classifyDocumentJson(long handle, String labelsJson);Classifies the document into one of the given labels by keywords, with scores and a prompt for LLM classification.
On NexPdfJni (static) · module conversion · C nexpdf_classify_document_json
readBarcodesJson
public static native String readBarcodesJson(long handle, int pageIndex, String optionsJson);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 NexPdfJni (static) · module conversion · C nexpdf_read_barcodes_json
readBarcodesImageJson
public static native String readBarcodesImageJson(byte[] image, String optionsJson);Reads the barcodes of a PNG or JPEG image, with positions in pixels.
On NexPdfJni (static) · module conversion · C nexpdf_read_barcodes_image_json
addBarcode
public static native boolean addBarcode(long handle, int pageIndex, double llx, double lly, double urx, double ury, String format, String text);Draws text as a vector barcode (white background, quiet zone) into a rectangle of a page, in PDF points.
On NexPdfJni (static) · module editor · C nexpdf_add_barcode
Annotations
addAnnotation
public static native boolean addAnnotation(long handle, int pageIndex, String kind, String colorHex, double opacity, 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 NexPdfJni (static) · module annotations · C nexpdf_add_annotation
addInk
public static native boolean addInk(long handle, int pageIndex, String colorHex, double strokeWidth, double opacity, String coords);Adds a freehand ink annotation. coords is "x,y;x,y;..." in PDF points.
On NexPdfJni (static) · module annotations · C nexpdf_add_ink
addLine
public static native boolean addLine(long handle, int pageIndex, String kind, String colorHex, double opacity, double strokeWidth, 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 NexPdfJni (static) · module annotations · C nexpdf_add_line
annotationsJson
public static native String annotationsJson(long handle, int pageIndex);The annotations of a page as JSON: num, gen, kind, color, contents and the rectangle.
On NexPdfJni (static) · always available · C nexpdf_annotations_json
removeAnnotation
public static native boolean removeAnnotation(long handle, int pageIndex, int num, int gen);Removes the annotation with object number num and generation gen from a page.
On NexPdfJni (static) · module annotations · C nexpdf_remove_annotation
moveAnnotation
public static native boolean moveAnnotation(long handle, int num, int gen, double dx, double dy);Moves an annotation by (dx, dy) PDF points.
On NexPdfJni (static) · module annotations · C nexpdf_move_annotation
setAnnotationContents
public static native boolean setAnnotationContents(long handle, int num, int gen, String contents);Replaces the text contents of an annotation.
On NexPdfJni (static) · module annotations · C nexpdf_set_annotation_contents
exportXfdf
public static native String exportXfdf(long handle);Exports every annotation as an XFDF document.
On NexPdfJni (static) · module annotations · C nexpdf_export_xfdf
importXfdf
public static native int importXfdf(long handle, String xfdf);Imports annotations from an XFDF document.
On NexPdfJni (static) · module annotations · C nexpdf_import_xfdf
flattenAnnotations
public static native int flattenAnnotations(long handle, int pageIndex);Burns annotations into the page content. A negative page index flattens every page.
On NexPdfJni (static) · module annotations · C nexpdf_flatten_annotations
addImageStamp
public static native boolean addImageStamp(long handle, int pageIndex, double llx, double lly, double urx, double ury, byte[] rgba, int width, int height, double opacity);Adds a picture stamp annotation from RGBA pixels (transparency kept). 1 on success.
On NexPdfJni (static) · module annotations · C nexpdf_add_image_stamp
addMeasurement
public static native String addMeasurement(long handle, int pageIndex, String json);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 NexPdfJni (static) · module annotations · C nexpdf_add_measurement
measurementsJson
public static native String measurementsJson(long handle);The stored measurements as JSON.
On NexPdfJni (static) · always available · C nexpdf_measurements_json
addFileAttachmentAnnot
public static native boolean addFileAttachmentAnnot(long handle, int pageIndex, double x, double y, String name, byte[] data, String mime, String description);Adds a paperclip annotation carrying a file; (x, y) is the top-left corner of the icon in PDF points.
On NexPdfJni (static) · module annotations · C nexpdf_add_file_attachment_annot
addInkSignature
public static native boolean addInkSignature(long handle, int pageIndex, String colorHex, double strokeWidth, String strokes);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 NexPdfJni (static) · module annotations · C nexpdf_add_ink_signature
replyToAnnotation
public static native int replyToAnnotation(long handle, int pageIndex, int num, int gen, String author, String text);Adds a reply by author to an annotation (or to another reply). Returns the reply object number (generation 0).
On NexPdfJni (static) · module annotations · C nexpdf_reply_to_annotation
annotationRepliesJson
public static native String annotationRepliesJson(long handle, int pageIndex, int num, int gen);The thread under an annotation, oldest first: num, gen, in_reply_to, author, date, text, state, state_model.
On NexPdfJni (static) · module annotations · C nexpdf_annotation_replies_json
setAnnotationState
public static native int setAnnotationState(long handle, int pageIndex, int num, int gen, String author, String state);Sets a review state (Accepted, Rejected, Cancelled, Completed, None) or marked state (Marked, Unmarked) as a hidden state reply. Returns its object number.
On NexPdfJni (static) · module annotations · C nexpdf_set_annotation_state
Forms
formFieldsJson
public static native String formFieldsJson(long handle);The form fields as JSON: name, kind, value, page, rectangle, read_only and required.
On NexPdfJni (static) · module forms · C nexpdf_form_fields_json
fillFormField
public static native boolean fillFormField(long handle, String name, String value);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 NexPdfJni (static) · module forms · C nexpdf_fill_form_field
addFormField
public static native boolean addFormField(long handle, int pageIndex, String kind, 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 NexPdfJni (static) · module forms · C nexpdf_add_form_field
flattenForms
public static native int flattenForms(long handle);Burns the form fields into the page content.
On NexPdfJni (static) · module forms · C nexpdf_flatten_forms
recalculateForms
public static native int recalculateForms(long handle);Runs every calculate script; returns how many fields changed.
On NexPdfJni (static) · module forms · C nexpdf_recalculate_forms
exportFormJson
public static native String exportFormJson(long handle);The field values as a JSON object.
On NexPdfJni (static) · module forms · C nexpdf_export_form_json
importFormJson
public static native int importFormJson(long handle, String json);Fills fields from a JSON object of names and values.
On NexPdfJni (static) · module forms · C nexpdf_import_form_json
exportFormFdf
public static native byte[] exportFormFdf(long handle, String pdfName);The field values as an FDF file; pdf_name is the file name recorded in it.
On NexPdfJni (static) · module forms · C nexpdf_export_form_fdf
importFormFdf
public static native int importFormFdf(long handle, byte[] fdf);Fills fields from an FDF file.
On NexPdfJni (static) · module forms · C nexpdf_import_form_fdf
exportFormXfdf
public static native String exportFormXfdf(long handle, String pdfName);The field values as XFDF.
On NexPdfJni (static) · module forms · C nexpdf_export_form_xfdf
importFormXfdf
public static native int importFormXfdf(long handle, String xfdf);Fills fields from XFDF.
On NexPdfJni (static) · module forms · C nexpdf_import_form_xfdf
XFA forms
xfaInfoJson
public static native String xfaInfoJson(long handle);Whether the document has XFA, whether it is dynamic, field and data counts and the XDP packets.
On NexPdfJni (static) · module forms · C nexpdf_xfa_info_json
xfaExportData
public static native String xfaExportData(long handle, String format);The XFA data as xml (default) or flat json ({"path":"value"}). Fails when the document has no XFA.
On NexPdfJni (static) · module forms · C nexpdf_xfa_export_data
xfaImportData
public static native int xfaImportData(long handle, String data, String format);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 NexPdfJni (static) · module forms · C nexpdf_xfa_import_data
xfaToAcroform
public static native int xfaToAcroform(long handle);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 NexPdfJni (static) · module forms · C nexpdf_xfa_to_acroform
xfaFlatten
public static native int xfaFlatten(long handle);Converts and flattens the XFA form: a plain PDF with the values drawn. Returns the number of flattened widgets.
On NexPdfJni (static) · module forms · C nexpdf_xfa_flatten
xfaRemove
public static native int xfaRemove(long handle);Removes XFA and keeps the AcroForm fields and pages: 1 removed, 0 no XFA.
On NexPdfJni (static) · module forms · C nexpdf_xfa_remove
Page editing
rotatePage
public static native boolean rotatePage(long handle, int pageIndex, int degrees);Rotates a page by a multiple of 90 degrees.
On NexPdfJni (static) · module editor · C nexpdf_rotate_page
deletePage
public static native boolean deletePage(long handle, int pageIndex);Deletes a page.
On NexPdfJni (static) · module editor · C nexpdf_delete_page
duplicatePage
public static native boolean duplicatePage(long handle, int pageIndex);Inserts a copy of a page after it.
On NexPdfJni (static) · module editor · C nexpdf_duplicate_page
addBlankPage
public static native boolean addBlankPage(long handle);Appends a blank page.
On NexPdfJni (static) · module editor · C nexpdf_add_blank_page
reversePages
public static native boolean reversePages(long handle);Reverses the page order.
On NexPdfJni (static) · module editor · C nexpdf_reverse_pages
movePage
public static native boolean movePage(long handle, int from, int to);Moves the page at from to index to.
On NexPdfJni (static) · module editor · C nexpdf_move_page
cropPage
public static native boolean cropPage(long handle, int pageIndex, double llx, double lly, double urx, double ury);Sets the crop box of a page (PDF points).
On NexPdfJni (static) · module editor · C nexpdf_crop_page
extractPages
public static native long extractPages(long handle, int[] pageIndices);A new document made of the given pages (split).
On NexPdfJni (static) · module editor · C nexpdf_extract_pages
appendDocument
public static native boolean appendDocument(long handle, long other);Appends the pages of another document (merge).
On NexPdfJni (static) · module editor · C nexpdf_append_document
insertImagePages
public static native int insertImagePages(long handle, int index, byte[] 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 NexPdfJni (static) · always available · C nexpdf_insert_image_pages
setPageBackground
public static native int setPageBackground(long handle, String optionsJson, byte[] rgb, int width, int 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 NexPdfJni (static) · module editor · C nexpdf_set_page_background
removePageBackground
public static native int removePageBackground(long handle, String pagesJson);Removes NexPDF backgrounds from the pages in pages_json ("[0,2]"), or from every page.
On NexPdfJni (static) · module editor · C nexpdf_remove_page_background
Content editing
pageContentJson
public static native String pageContentJson(long handle, int pageIndex);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 NexPdfJni (static) · module editor · C nexpdf_page_content_json
editText
public static native boolean editText(long handle, int pageIndex, String id, String changeJson);Edits a text line: {text?, size?, color?, dx?, dy?, family?, bold?, italic?}. Empty text deletes it.
On NexPdfJni (static) · module editor · C nexpdf_edit_text
addPageText
public static native boolean addPageText(long handle, int pageIndex, String json);Adds editable page text: {text, x, y (baseline), size, color, family, bold, italic}.
On NexPdfJni (static) · module editor · C nexpdf_add_page_text
deleteContent
public static native boolean deleteContent(long handle, int pageIndex, String id);Deletes a text line or an image of the page content.
On NexPdfJni (static) · module editor · C nexpdf_delete_content
transformImage
public static native boolean transformImage(long handle, int pageIndex, String id, double llx, double lly, double urx, double ury);Moves or resizes an image to a rectangle (PDF points).
On NexPdfJni (static) · module editor · C nexpdf_transform_image
replaceImage
public static native boolean replaceImage(long handle, int pageIndex, String id, byte[] rgb, int width, int height);Replaces an image with RGB pixels (width x height x 3 bytes).
On NexPdfJni (static) · module editor · C nexpdf_replace_image
editTextBlock
public static native boolean editTextBlock(long handle, int pageIndex, String text, String colorHex, double fontSize, boolean bold, boolean italic, boolean replaceExisting, 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 NexPdfJni (static) · module editor · C nexpdf_edit_text_block
Metadata, bookmarks, layers and attachments
metadataJson
public static native String metadataJson(long handle);The document information (title, author, subject, keywords, ...) as JSON.
On NexPdfJni (static) · always available · C nexpdf_metadata_json
setMetadata
public static native boolean setMetadata(long handle, String title, String author, String subject, String keywords);Sets the title, author, subject and keywords. Omitted (null) values keep the current one.
On NexPdfJni (static) · module editor · C nexpdf_set_metadata
outlinesJson
public static native String outlinesJson(long handle);The bookmarks as JSON: [{"title","page","children":[...]}].
On NexPdfJni (static) · always available · C nexpdf_outlines_json
setOutlinesJson
public static native boolean setOutlinesJson(long handle, String json);Replaces the bookmarks with a JSON tree in the same shape.
On NexPdfJni (static) · module editor · C nexpdf_set_outlines_json
pageLabelsJson
public static native String pageLabelsJson(long handle);Page labels: {"labels":["i","ii","1"],"ranges":[{"start":0,"style":"roman","prefix":"","first":1}]}.
On NexPdfJni (static) · always available · C nexpdf_page_labels_json
setPageLabelsJson
public static native boolean setPageLabelsJson(long handle, String rangesJson);Sets the page label ranges ([] removes the labels). Styles: decimal, roman, ROMAN, letters, LETTERS, none.
On NexPdfJni (static) · module editor · C nexpdf_set_page_labels_json
layersJson
public static native String layersJson(long handle);The optional content groups (layers): [{"num","gen","name","visible","printable"}].
On NexPdfJni (static) · always available · C nexpdf_layers_json
setLayerVisible
public static native boolean setLayerVisible(long handle, int num, int gen, boolean visible);Shows or hides a layer.
On NexPdfJni (static) · always available · C nexpdf_set_layer_visible
attachmentsJson
public static native String attachmentsJson(long handle);The embedded files: [{"name","description","mime","size","page"}]; page is null for document-level files.
On NexPdfJni (static) · always available · C nexpdf_attachments_json
attachmentData
public static native byte[] attachmentData(long handle, String name);The bytes of an embedded file.
On NexPdfJni (static) · always available · C nexpdf_attachment_data
addAttachment
public static native boolean addAttachment(long handle, String name, byte[] data, String mime, String description);Embeds a file at document level.
On NexPdfJni (static) · module editor · C nexpdf_add_attachment
removeAttachment
public static native boolean removeAttachment(long handle, String name);Removes an embedded file.
On NexPdfJni (static) · module editor · C nexpdf_remove_attachment
Encryption, watermarks and stamping
encryptAes256
public static native boolean encryptAes256(long handle, String userPw, String ownerPw);Encrypts with AES-256 using a user (open) password and an owner password.
On NexPdfJni (static) · module security · C nexpdf_encrypt_aes256
encryptWithPermissions
public static native boolean encryptWithPermissions(long handle, String userPw, String ownerPw, int permissions);Encrypts with AES-256 and a permission mask: print 1, modify 2, copy 4, annotate 8, fill forms 16, assemble 32.
On NexPdfJni (static) · module security · C nexpdf_encrypt_with_permissions
securityJson
public static native String securityJson(long handle);The encryption state: {"encrypted","revision","owner","print","modify","copy","annotate","fill_forms","assemble"}.
On NexPdfJni (static) · always available · C nexpdf_security_json
removePassword
public static native boolean removePassword(long handle, String ownerPassword);Removes the protection. Needs owner access: the document was opened with the owner password, or pass it here.
On NexPdfJni (static) · module security · C nexpdf_remove_password
addWatermark
public static native boolean addWatermark(long handle, String text);Stamps a text watermark on every page.
On NexPdfJni (static) · module security · C nexpdf_add_watermark
removeWatermarks
public static native int removeWatermarks(long handle);Removes the watermarks NexPDF added.
On NexPdfJni (static) · module security · C nexpdf_remove_watermarks
addHeaderFooter
public static native boolean addHeaderFooter(long handle, String header, String footer, double fontSize);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 NexPdfJni (static) · module security · C nexpdf_add_header_footer
addBates
public static native boolean addBates(long handle, String prefix, long start, int digits);Adds Bates numbering: prefix, first number and number of digits.
On NexPdfJni (static) · module security · C nexpdf_add_bates
Redaction
applyRedaction
public static native boolean applyRedaction(long handle, int pageIndex, double llx, double lly, double urx, double ury, boolean fillWhite);Permanently removes the text, images and annotations under a rectangle and paints an opaque box over it, black or white.
On NexPdfJni (static) · module redaction · C nexpdf_apply_redaction
redactMatches
public static native int redactMatches(long handle, String query, int mode, boolean fillWhite);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 NexPdfJni (static) · module redaction · C nexpdf_redact_matches
Digital signatures
signPades
public static native byte[] signPades(long handle, String signer, String reason, String location);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 NexPdfJni (static) · module signatures · C nexpdf_sign_pades
signPkcs12
public static native byte[] signPkcs12(long handle, byte[] p12, String password, String optionsJson);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 NexPdfJni (static) · module signatures · C nexpdf_sign_pkcs12
pkcs12InfoJson
public static native String pkcs12InfoJson(byte[] p12, String password);The certificate summary of a PKCS#12 file; fails with "incorrect password" on a wrong password.
On NexPdfJni (static) · module signatures · C nexpdf_pkcs12_info_json
prepareExternalSignature
public static native byte[] prepareExternalSignature(long handle, byte[] cert, String optionsJson);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 NexPdfJni (static) · module signatures · C nexpdf_prepare_external_signature
externalSignatureData
public static native byte[] externalSignatureData(byte[] prepared, byte[] cert);External signing, step 2: the bytes to sign (DER signed attributes; sign their SHA-256 on devices that take a digest).
On NexPdfJni (static) · module signatures · C nexpdf_external_signature_data
completeExternalSignature
public static native byte[] completeExternalSignature(byte[] prepared, byte[] cert, byte[] signature, int algorithm, String optionsJson);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 NexPdfJni (static) · module signatures · C nexpdf_complete_external_signature
verifySignaturesJson
public static native String verifySignaturesJson(byte[] pdfBytes);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 NexPdfJni (static) · always available · C nexpdf_verify_signatures_json
verifySignaturesWithRootsJson
public static native String verifySignaturesWithRootsJson(byte[] pdfBytes, String rootsPem);Verifies the signatures treating the PEM certificates in roots_pem as trust anchors.
On NexPdfJni (static) · module signatures · C nexpdf_verify_signatures_with_roots_json
addLtv
public static native byte[] addLtv(byte[] pdfBytes);Adds long-term validation data (DSS with OCSP responses and CRLs) to a signed file.
On NexPdfJni (static) · module signatures · C nexpdf_add_ltv
addDocumentTimestamp
public static native byte[] addDocumentTimestamp(long handle, String optionsJson);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 NexPdfJni (static) · module signatures · C nexpdf_add_document_timestamp
addDocumentTimestampBytes
public static native byte[] addDocumentTimestampBytes(byte[] pdfBytes, String optionsJson);Adds a document timestamp to the bytes of a PDF file (for example straight from signing). Same options. Returns the new file.
On NexPdfJni (static) · module signatures · C nexpdf_add_document_timestamp_bytes
prepareDocumentTimestamp
public static native byte[] prepareDocumentTimestamp(long handle, String optionsJson);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 NexPdfJni (static) · module signatures · C nexpdf_prepare_document_timestamp
documentTimestampRequest
public static native byte[] documentTimestampRequest(byte[] prepared, String hash);Document timestamp, step 2: the DER TimeStampReq to send to the TSA as application/timestamp-query (hash SHA-256 by default).
On NexPdfJni (static) · module signatures · C nexpdf_document_timestamp_request
completeDocumentTimestamp
public static native byte[] completeDocumentTimestamp(byte[] prepared, byte[] token);Document timestamp, step 3: the timestamped PDF, from the prepared file and the TSA token (TimeStampResp or TimeStampToken).
On NexPdfJni (static) · module signatures · C nexpdf_complete_document_timestamp
PDF/A, PDF/X and PDF/UA
convertPdfA
public static native boolean convertPdfA(long handle);Converts the document to PDF/A (ISO 19005) for archiving.
On NexPdfJni (static) · module standards · C nexpdf_convert_pdfa
convertPdfX
public static native boolean convertPdfX(long handle);Converts the document to PDF/X for print exchange.
On NexPdfJni (static) · module standards · C nexpdf_convert_pdfx
autoTag
public static native String autoTag(long handle, String lang, boolean 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 NexPdfJni (static) · module standards · C nexpdf_auto_tag
validatePdfaJson
public static native String validatePdfaJson(long handle, String level);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 NexPdfJni (static) · module standards · C nexpdf_validate_pdfa_json
validatePdfuaJson
public static native String validatePdfuaJson(long handle);PDF/UA validation (PDF/UA-1, or PDF/UA-2 when declared), with the same report as PDF/A validation.
On NexPdfJni (static) · module standards · C nexpdf_validate_pdfua_json
convertPdfaLevel
public static native boolean convertPdfaLevel(long handle, String level);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 NexPdfJni (static) · module standards · C nexpdf_convert_pdfa_level
OCR
ocrJson
public static native String ocrJson(long handle, String optionsJson);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 NexPdfJni (static) · module ocr · C nexpdf_ocr
ocrLoadModel
public static native boolean ocrLoadModel(String optionsJson, byte[] model, String dictionary);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 NexPdfJni (static) · module ocr · C nexpdf_ocr_load_model
ocrModelsJson
public static native String ocrModelsJson();The loaded OCR models: kind, name, languages, symbols, size.
On NexPdfJni (static) · module ocr · C nexpdf_ocr_models_json
ocrUnloadModels
public static native int ocrUnloadModels(String languages);Unloads the OCR models of the given languages (all when empty). Returns the number removed.
On NexPdfJni (static) · module ocr · C nexpdf_ocr_unload_models
Compare, optimise and memory
compareJson
public static native String compareJson(long a, long b, double dpi);Compares two documents (text and visual differences per page) at the given resolution, as JSON.
On NexPdfJni (static) · always available · C nexpdf_compare_json
compareOverlayPng
public static native byte[] compareOverlayPng(long a, long b, int pageIndex, double dpi);A PNG overlay of the visual differences of one page of two documents.
On NexPdfJni (static) · always available · C nexpdf_compare_overlay_png
optimize
public static native String optimize(long handle);Optimises the document (removes unused objects, recompresses streams); returns a JSON report.
On NexPdfJni (static) · module editor · C nexpdf_optimize
subsetFonts
public static native String subsetFonts(long handle);Subsets the embedded fonts to the glyphs the document uses; returns a JSON report.
On NexPdfJni (static) · module editor · C nexpdf_subset_fonts
trimMemory
public static native long trimMemory(long handle);Drops cached data of the document; returns the bytes freed.
On NexPdfJni (static) · always available · C nexpdf_trim_memory
memoryUsageBytes
public static native long memoryUsageBytes(long handle);Approximate memory used by the document, in bytes.
On NexPdfJni (static) · always available · C nexpdf_memory_usage_bytes
compareTextJson
public static native String compareTextJson(long oldHandle, long newHandle, String optionsJson);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 NexPdfJni (static) · always available · C nexpdf_compare_text_json
compareAnnotate
public static native byte[] compareAnnotate(long oldHandle, long newHandle, String optionsJson);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 NexPdfJni (static) · always available · C nexpdf_compare_annotate