API reference
Every class, method and function of the NexPDF React Native SDK, grouped by feature. Generated from NexPDF 1.1.0.
Generated from NexPDF 1.1.0
This page is generated from the sources of @nexdevit/nexpdf-react-native. It lists 191 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
activateLicense
NexPdf.activateLicense(keyOrXml: string, appId: string): Promise<number>Activates a license XML or key for this app (package name / bundle id). Returns 2 (licensed) or 1 (trial).
On NexPdf
licenseStatus
NexPdf.licenseStatus()On NexPdf
version
NexPdf.version()On NexPdf
open
NexPdf.open(base64: string, password?: string): Promise<PdfDocument>Opens a PDF (or Word / Excel / PowerPoint, an EPUB / FictionBook / XPS book or a CBZ comic, converted) from base64.
On NexPdf
fromHtml
NexPdf.fromHtml(html: string)On NexPdf
verifySignatures
NexPdf.verifySignatures(signedPdfBase64: string)On NexPdf
Ready-made reader
open
NexPdfReader.open(options: OpenReaderOptions = {}): Promise<void>Presents the reader full screen. Resolves once it is shown; listen for closed to know when it is dismissed.
On NexPdfReader
close
NexPdfReader.close(): Promise<void>Closes the reader if it is open.
On NexPdfReader
Library and licensing
version
NexPdf.api.version(): Promise<string>The engine version.
On NexPdf.api · always available · C nexpdf_version
licenseActivate
NexPdf.api.licenseActivate(keyOrXml?: string | null, platform?: string | null, appId?: string | null): Promise<number>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.api · always available · C nexpdf_license_activate
licenseStatusJson
NexPdf.api.licenseStatusJson(): Promise<string>The active license as JSON: state (unlicensed, trial or licensed), licensee, id, tier, modules, expires_at, days_left and watermark.
On NexPdf.api · always available · C nexpdf_license_status_json
registerStandardFont
NexPdf.api.registerStandardFont(data: string): Promise<number>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.api · always available · C nexpdf_register_standard_font
hasBundledFonts
NexPdf.api.hasBundledFonts(): Promise<number>1 when the Liberation fonts are compiled in, 0 in the lighter builds.
On NexPdf.api · always available · C nexpdf_has_bundled_fonts
Opening and saving
openBytes
NexPdf.api.openBytes(data: string): Promise<PdfDocument>Opens a PDF from bytes. JPEG, PNG and TIFF pictures are also accepted (one page per picture).
On NexPdf.api · always available · C nexpdf_open_bytes
openBytesWithPassword
NexPdf.api.openBytesWithPassword(data: string, password?: string | null): Promise<PdfDocument>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 NexPdf.api · always available · C nexpdf_open_bytes_with_password
fromHtml
NexPdf.api.fromHtml(html?: string | null): Promise<PdfDocument>Lays out HTML as a new PDF document.
On NexPdf.api · module conversion · C nexpdf_from_html
openOffice
NexPdf.api.openOffice(data: string): Promise<PdfDocument>Converts Word, Excel or PowerPoint bytes (format detected) to a new PDF document.
On NexPdf.api · module conversion · C nexpdf_open_office
openEbook
NexPdf.api.openEbook(data: string): Promise<PdfDocument>Converts EPUB, FictionBook (.fb2, .fb2.zip), XPS/OpenXPS or a CBZ comic archive to a new PDF document.
On NexPdf.api · module conversion · C nexpdf_open_ebook
openImage
NexPdf.api.openImage(data: string): Promise<PdfDocument>Converts JPEG, PNG or TIFF bytes to a new PDF, one page per picture.
On NexPdf.api · always available · C nexpdf_open_image
saveBytes
doc.saveBytes(): Promise<string>The document, with every change, as PDF bytes (full rewrite).
On PdfDocument · always available · C nexpdf_save_bytes
saveLinearized
doc.saveLinearized(): Promise<string>A linearized ("Fast Web View") PDF: the first page shows before the download ends.
On PdfDocument · always available · C nexpdf_save_linearized
Pages and rendering
pageCount
doc.pageCount(): Promise<number>Number of pages.
On PdfDocument · always available · C nexpdf_page_count
pageWidth
doc.pageWidth(pageIndex: number): Promise<number>Displayed page width in points (crop box, rotation and /UserUnit applied).
On PdfDocument · always available · C nexpdf_page_width
pageHeight
doc.pageHeight(pageIndex: number): Promise<number>Displayed page height in points (crop box, rotation and /UserUnit applied).
On PdfDocument · always available · C nexpdf_page_height
pageViewJson
doc.pageViewJson(pageIndex: number): Promise<string>How the page is displayed: width, height, rotation, user_unit, crop and the PDF-to-display matrix to_display.
On PdfDocument · always available · C nexpdf_page_view_json
renderPagePng
doc.renderPagePng(pageIndex: number, dpi: number): Promise<string>Renders a page to PNG at the given resolution (dots per inch). Unlicensed and trial renders carry a watermark.
On PdfDocument · always available · C nexpdf_render_page_png
renderThumbPng
doc.renderThumbPng(pageIndex: number, maxDim: number): Promise<string>Renders a thumbnail PNG whose longer side is at most max_dim pixels.
On PdfDocument · always available · C nexpdf_render_thumb_png
setOverprint
doc.setOverprint(mode: number): Promise<number>Overprint simulation for later renders: 0 = PDF/X documents only (default), 1 = always, 2 = never.
On PdfDocument · always available · C nexpdf_set_overprint
Text, search and assistant
extractPageText
doc.extractPageText(pageIndex: number): Promise<string>The text of a page in reading order.
On PdfDocument · always available · C nexpdf_extract_page_text
extractMarkdown
doc.extractMarkdown(): Promise<string>The whole document as Markdown (headings, lists, tables).
On PdfDocument · always available · C nexpdf_extract_markdown
searchJson
doc.searchJson(query?: string | null): Promise<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 PdfDocument · always available · C nexpdf_search_json
pageBlocksJson
doc.pageBlocksJson(pageIndex: number): Promise<string>The text blocks of a page as JSON: text, font size and the rectangle llx, lly, urx, ury.
On PdfDocument · always available · C nexpdf_page_blocks_json
askDocument
doc.askDocument(question: string | null, k: number, maxChars: number): Promise<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 PdfDocument · always available · C nexpdf_ask_document
pageWordsJson
doc.pageWordsJson(pageIndex: number, optionsJson?: string | null): Promise<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 PdfDocument · always available · C nexpdf_page_words_json
Conversion
toHtml
doc.toHtml(): Promise<string>The document as HTML.
On PdfDocument · module conversion · C nexpdf_to_html
toJson
doc.toJson(): Promise<string>The document content as JSON.
On PdfDocument · module conversion · C nexpdf_to_json
toXml
doc.toXml(): Promise<string>The document content as XML.
On PdfDocument · module conversion · C nexpdf_to_xml
toCsv
doc.toCsv(): Promise<string>Tables of the document as CSV.
On PdfDocument · module conversion · C nexpdf_to_csv
toRtf
doc.toRtf(): Promise<string>The document as RTF.
On PdfDocument · module conversion · C nexpdf_to_rtf
toDocx
doc.toDocx(): Promise<string>The document as a Word (.docx) file.
On PdfDocument · module conversion · C nexpdf_to_docx
toXlsx
doc.toXlsx(): Promise<string>The document as an Excel workbook, one sheet per page.
On PdfDocument · module conversion · C nexpdf_to_xlsx
toPptx
doc.toPptx(): Promise<string>The document as a PowerPoint presentation, one slide per page.
On PdfDocument · module conversion · C nexpdf_to_pptx
toReflowHtml
doc.toReflowHtml(optionsJson?: string | null): Promise<string>The text as responsive HTML for small screens. Options (may be omitted): {"pages":[0],"images":true,"full_page":true,"title":"..."}.
On PdfDocument · module conversion · C nexpdf_to_reflow_html
openXlsxWithClock
NexPdf.api.openXlsxWithClock(data: string, clockUnixSeconds: number): Promise<PdfDocument>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 NexPdf.api · module conversion · C nexpdf_open_xlsx_with_clock
openDocxWithOptionsJson
NexPdf.api.openDocxWithOptionsJson(data: string, optionsJson?: string | null): Promise<PdfDocument>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 NexPdf.api · module conversion · C nexpdf_open_docx_with_options_json
Templates
templateDocxToPdf
NexPdf.api.templateDocxToPdf(templateBytes: string, dataJson?: string | null, optionsJson?: string | null): Promise<PdfDocument>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 NexPdf.api · module conversion · C nexpdf_template_docx_to_pdf
templateDocxFill
NexPdf.api.templateDocxFill(templateBytes: string, dataJson?: string | null): Promise<string>Fills a Word template with JSON data and returns the new .docx bytes.
On NexPdf.api · module conversion · C nexpdf_template_docx_fill
templateHtmlToPdf
NexPdf.api.templateHtmlToPdf(htmlUtf8?: string | null, dataJson?: string | null, optionsJson?: string | null): Promise<PdfDocument>Fills an HTML template with JSON data (values HTML-escaped, {{{raw}}} not) and lays it out as a new PDF document.
On NexPdf.api · module conversion · C nexpdf_template_html_to_pdf
templateFillPdf
doc.templateFillPdf(dataJson?: string | null, optionsJson?: string | null): Promise<number>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 PdfDocument · module conversion · C nexpdf_template_fill_pdf
templateDocxFillWith
NexPdf.api.templateDocxFillWith(templateBytes: string, dataJson?: string | null, optionsJson?: string | null): Promise<string>Fills a Word template with JSON data and options {"strict","locale"}, and returns the new .docx bytes.
On NexPdf.api · module conversion · C nexpdf_template_docx_fill_with
Office editing
xlsxEdit
NexPdf.api.xlsxEdit(data: string, editsJson?: string | null): Promise<string>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.api · module conversion · C nexpdf_xlsx_edit
xlsxCellsJson
NexPdf.api.xlsxCellsJson(data: string, optionsJson?: string | null): Promise<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.api · module conversion · C nexpdf_xlsx_cells_json
docxEdit
NexPdf.api.docxEdit(data: string, opsJson?: string | null): Promise<string>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.api · module conversion · C nexpdf_docx_edit
docxParagraphsJson
NexPdf.api.docxParagraphsJson(data: string): Promise<string>The paragraphs of a Word document as JSON: index, style, text and whether each is in a table.
On NexPdf.api · module conversion · C nexpdf_docx_paragraphs_json
Structured extraction and barcodes
extractTablesJson
doc.extractTablesJson(pageIndex: number, optionsJson?: string | null): Promise<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 PdfDocument · module conversion · C nexpdf_extract_tables_json
extractKeyValuesJson
doc.extractKeyValuesJson(optionsJson?: string | null): Promise<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 PdfDocument · module conversion · C nexpdf_extract_key_values_json
extractionPromptJson
doc.extractionPromptJson(schemaJson?: string | null, optionsJson?: string | null): Promise<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 PdfDocument · module conversion · C nexpdf_extraction_prompt_json
extractionValidateJson
doc.extractionValidateJson(schemaJson?: string | null, answerJson?: string | null): Promise<string>Validates and coerces a model answer against the schema and grounds each value on the pages: valid, value, errors, warnings, fields.
On PdfDocument · module conversion · C nexpdf_extraction_validate_json
classifyDocumentJson
doc.classifyDocumentJson(labelsJson?: string | null): Promise<string>Classifies the document into one of the given labels by keywords, with scores and a prompt for LLM classification.
On PdfDocument · module conversion · C nexpdf_classify_document_json
readBarcodesJson
doc.readBarcodesJson(pageIndex: number, optionsJson?: string | null): Promise<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 PdfDocument · module conversion · C nexpdf_read_barcodes_json
readBarcodesImageJson
NexPdf.api.readBarcodesImageJson(data: string, optionsJson?: string | null): Promise<string>Reads the barcodes of a PNG or JPEG image, with positions in pixels.
On NexPdf.api · module conversion · C nexpdf_read_barcodes_image_json
addBarcode
doc.addBarcode(pageIndex: number, llx: number, lly: number, urx: number, ury: number, format?: string | null, text?: string | null): Promise<number>Draws text as a vector barcode (white background, quiet zone) into a rectangle of a page, in PDF points.
On PdfDocument · module editor · C nexpdf_add_barcode
addBarcodeEx
doc.addBarcodeEx(pageIndex: number, llx: number, lly: number, urx: number, ury: number, format?: string | null, text?: string | null, optionsJson?: string | null): Promise<number>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 PdfDocument · module editor · C nexpdf_add_barcode_ex
Annotations
addAnnotation
doc.addAnnotation(pageIndex: number, kind: string | null, colorHex: string | null, opacity: number, contents: string | null, llx: number, lly: number, urx: number, ury: number): Promise<number>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 PdfDocument · module annotations · C nexpdf_add_annotation
addInk
doc.addInk(pageIndex: number, colorHex: string | null, strokeWidth: number, opacity: number, coords?: string | null): Promise<number>Adds a freehand ink annotation. coords is "x,y;x,y;..." in PDF points.
On PdfDocument · module annotations · C nexpdf_add_ink
addLine
doc.addLine(pageIndex: number, kind: string | null, colorHex: string | null, opacity: number, strokeWidth: number, x1: number, y1: number, x2: number, y2: number): Promise<number>Adds a line or arrow (kind is Line or Arrow) from (x1, y1) to (x2, y2) in PDF points.
On PdfDocument · module annotations · C nexpdf_add_line
annotationsJson
doc.annotationsJson(pageIndex: number): Promise<string>The annotations of a page as JSON: num, gen, kind, color, contents and the rectangle.
On PdfDocument · always available · C nexpdf_annotations_json
removeAnnotation
doc.removeAnnotation(pageIndex: number, num: number, generation: number): Promise<number>Removes the annotation with object number num and generation gen from a page.
On PdfDocument · module annotations · C nexpdf_remove_annotation
moveAnnotation
doc.moveAnnotation(num: number, generation: number, dx: number, dy: number): Promise<number>Moves an annotation by (dx, dy) PDF points.
On PdfDocument · module annotations · C nexpdf_move_annotation
setAnnotationContents
doc.setAnnotationContents(num: number, generation: number, contents?: string | null): Promise<number>Replaces the text contents of an annotation.
On PdfDocument · module annotations · C nexpdf_set_annotation_contents
exportXfdf
doc.exportXfdf(): Promise<string>Exports every annotation as an XFDF document.
On PdfDocument · module annotations · C nexpdf_export_xfdf
importXfdf
doc.importXfdf(xfdf?: string | null): Promise<number>Imports annotations from an XFDF document.
On PdfDocument · module annotations · C nexpdf_import_xfdf
flattenAnnotations
doc.flattenAnnotations(pageIndex: number): Promise<number>Burns annotations into the page content. A negative page index flattens every page.
On PdfDocument · module annotations · C nexpdf_flatten_annotations
addImageStamp
doc.addImageStamp(page: number, llx: number, lly: number, urx: number, ury: number, rgba: string, width: number, height: number, opacity: number): Promise<number>Adds a picture stamp annotation from RGBA pixels (transparency kept). 1 on success.
On PdfDocument · module annotations · C nexpdf_add_image_stamp
addMeasurement
doc.addMeasurement(page: number, json?: string | null): Promise<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 PdfDocument · module annotations · C nexpdf_add_measurement
measurementsJson
doc.measurementsJson(): Promise<string>The stored measurements as JSON.
On PdfDocument · always available · C nexpdf_measurements_json
addFileAttachmentAnnot
doc.addFileAttachmentAnnot(pageIndex: number, x: number, y: number, name: string | null, data: string, mime?: string | null, description?: string | null): Promise<number>Adds a paperclip annotation carrying a file; (x, y) is the top-left corner of the icon in PDF points.
On PdfDocument · module annotations · C nexpdf_add_file_attachment_annot
addInkSignature
doc.addInkSignature(pageIndex: number, colorHex: string | null, strokeWidth: number, strokes?: string | null): Promise<number>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 PdfDocument · module annotations · C nexpdf_add_ink_signature
replyToAnnotation
doc.replyToAnnotation(pageIndex: number, num: number, generation: number, author?: string | null, text?: string | null): Promise<number>Adds a reply by author to an annotation (or to another reply). Returns the reply object number (generation 0).
On PdfDocument · module annotations · C nexpdf_reply_to_annotation
annotationRepliesJson
doc.annotationRepliesJson(pageIndex: number, num: number, generation: number): Promise<string>The thread under an annotation, oldest first: num, gen, in_reply_to, author, date, text, state, state_model.
On PdfDocument · module annotations · C nexpdf_annotation_replies_json
setAnnotationState
doc.setAnnotationState(pageIndex: number, num: number, generation: number, author?: string | null, state?: string | null): Promise<number>Sets a review state (Accepted, Rejected, Cancelled, Completed, None) or marked state (Marked, Unmarked) as a hidden state reply. Returns its object number.
On PdfDocument · module annotations · C nexpdf_set_annotation_state
Forms
formFieldsJson
doc.formFieldsJson(): Promise<string>The form fields as JSON: name, kind, value, page, rectangle, read_only and required.
On PdfDocument · module forms · C nexpdf_form_fields_json
fillFormField
doc.fillFormField(name?: string | null, value?: string | null): Promise<number>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 PdfDocument · module forms · C nexpdf_fill_form_field
setSignatureAppearance
doc.setSignatureAppearance(name: string | null, rgba: string, width: number, height: number): Promise<number>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 PdfDocument · module forms · C nexpdf_set_signature_appearance
addFormField
doc.addFormField(pageIndex: number, kind: string | null, name: string | null, llx: number, lly: number, urx: number, ury: number): Promise<number>Adds a form field named name in a rectangle of a page. kind: text (default), checkbox, radio, combobox, listbox, button, signature or barcode.
On PdfDocument · module forms · C nexpdf_add_form_field
flattenForms
doc.flattenForms(): Promise<number>Burns the form fields into the page content.
On PdfDocument · module forms · C nexpdf_flatten_forms
recalculateForms
doc.recalculateForms(): Promise<number>Runs every calculate script; returns how many fields changed.
On PdfDocument · module forms · C nexpdf_recalculate_forms
exportFormJson
doc.exportFormJson(): Promise<string>The field values as a JSON object.
On PdfDocument · module forms · C nexpdf_export_form_json
importFormJson
doc.importFormJson(json?: string | null): Promise<number>Fills fields from a JSON object of names and values.
On PdfDocument · module forms · C nexpdf_import_form_json
exportFormFdf
doc.exportFormFdf(pdfName?: string | null): Promise<string>The field values as an FDF file; pdf_name is the file name recorded in it.
On PdfDocument · module forms · C nexpdf_export_form_fdf
importFormFdf
doc.importFormFdf(data: string): Promise<number>Fills fields from an FDF file.
On PdfDocument · module forms · C nexpdf_import_form_fdf
exportFormXfdf
doc.exportFormXfdf(pdfName?: string | null): Promise<string>The field values as XFDF.
On PdfDocument · module forms · C nexpdf_export_form_xfdf
importFormXfdf
doc.importFormXfdf(xfdf?: string | null): Promise<number>Fills fields from XFDF.
On PdfDocument · module forms · C nexpdf_import_form_xfdf
XFA forms
xfaInfoJson
doc.xfaInfoJson(): Promise<string>Whether the document has XFA, whether it is dynamic, field and data counts and the XDP packets.
On PdfDocument · module forms · C nexpdf_xfa_info_json
xfaExportData
doc.xfaExportData(format?: string | null): Promise<string>The XFA data as xml (default) or flat json ({"path":"value"}). Fails when the document has no XFA.
On PdfDocument · module forms · C nexpdf_xfa_export_data
xfaImportData
doc.xfaImportData(data?: string | null, format?: string | null): Promise<number>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 PdfDocument · module forms · C nexpdf_xfa_import_data
xfaToAcroform
doc.xfaToAcroform(): Promise<number>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 PdfDocument · module forms · C nexpdf_xfa_to_acroform
xfaFlatten
doc.xfaFlatten(): Promise<number>Converts and flattens the XFA form: a plain PDF with the values drawn. Returns the number of flattened widgets.
On PdfDocument · module forms · C nexpdf_xfa_flatten
xfaRemove
doc.xfaRemove(): Promise<number>Removes XFA and keeps the AcroForm fields and pages: 1 removed, 0 no XFA.
On PdfDocument · module forms · C nexpdf_xfa_remove
xfaToAcroformJson
doc.xfaToAcroformJson(optionsJson?: string | null): Promise<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 PdfDocument · module forms · C nexpdf_xfa_to_acroform_json
xfaRunScriptsJson
doc.xfaRunScriptsJson(): Promise<string>Runs the initialize, calculate and validate scripts (FormCalc and JavaScript) and stores calculated values in the data: data_changed, warnings, validation_errors.
On PdfDocument · module forms · C nexpdf_xfa_run_scripts_json
registerFallbackFont
NexPdf.api.registerFallbackFont(data: string): Promise<number>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.api · module forms · C nexpdf_register_fallback_font
Real-time collaboration
syncExportJson
doc.syncExportJson(sinceVersion: number): Promise<string>NexPDF Sync: every change (from any client) with a Lamport clock above since_version, as a nexpdf-sync/1 change set.
On PdfDocument · module annotations · C nexpdf_sync_export_json
syncExportLocalJson
doc.syncExportLocalJson(sinceVersion: number): Promise<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 PdfDocument · module annotations · C nexpdf_sync_export_local_json
syncApplyJson
doc.syncApplyJson(changesJson?: string | null): Promise<string>NexPDF Sync: applies remote changes, last writer wins per record. Returns ok, clock, applied, ignored, conflicts and errors.
On PdfDocument · module annotations · C nexpdf_sync_apply_json
syncSnapshotJson
doc.syncSnapshotJson(): Promise<string>NexPDF Sync: every record with its version, base records and tombstones included.
On PdfDocument · module annotations · C nexpdf_sync_snapshot_json
syncSetClientId
doc.syncSetClientId(clientId?: string | null): Promise<number>NexPDF Sync: the client id this copy versions its changes under (1 to 64 characters of [A-Za-z0-9-_.:@]).
On PdfDocument · module annotations · C nexpdf_sync_set_client_id
Page editing
rotatePage
doc.rotatePage(pageIndex: number, degrees: number): Promise<number>Rotates a page by a multiple of 90 degrees.
On PdfDocument · module editor · C nexpdf_rotate_page
deletePage
doc.deletePage(pageIndex: number): Promise<number>Deletes a page.
On PdfDocument · module editor · C nexpdf_delete_page
duplicatePage
doc.duplicatePage(pageIndex: number): Promise<number>Inserts a copy of a page after it.
On PdfDocument · module editor · C nexpdf_duplicate_page
addBlankPage
doc.addBlankPage(): Promise<number>Appends a blank page.
On PdfDocument · module editor · C nexpdf_add_blank_page
reversePages
doc.reversePages(): Promise<number>Reverses the page order.
On PdfDocument · module editor · C nexpdf_reverse_pages
movePage
doc.movePage(from: number, to: number): Promise<number>Moves the page at from to index to.
On PdfDocument · module editor · C nexpdf_move_page
cropPage
doc.cropPage(pageIndex: number, llx: number, lly: number, urx: number, ury: number): Promise<number>Sets the crop box of a page (PDF points).
On PdfDocument · module editor · C nexpdf_crop_page
extractPages
doc.extractPages(indices: number[]): Promise<PdfDocument>A new document made of the given pages (split).
On PdfDocument · module editor · C nexpdf_extract_pages
appendDocument
doc.appendDocument(other: PdfDocument): Promise<number>Appends the pages of another document (merge).
On PdfDocument · module editor · C nexpdf_append_document
insertImagePages
doc.insertImagePages(index: number, data: string): Promise<number>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 PdfDocument · always available · C nexpdf_insert_image_pages
setPageBackground
doc.setPageBackground(optionsJson: string | null, rgb: string, width: number, height: number): Promise<number>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 PdfDocument · module editor · C nexpdf_set_page_background
removePageBackground
doc.removePageBackground(pagesJson?: string | null): Promise<number>Removes NexPDF backgrounds from the pages in pages_json ("[0,2]"), or from every page.
On PdfDocument · module editor · C nexpdf_remove_page_background
Content editing
pageContentJson
doc.pageContentJson(page: number): Promise<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 PdfDocument · module editor · C nexpdf_page_content_json
editText
doc.editText(page: number, id?: string | null, changeJson?: string | null): Promise<number>Edits a text line: {text?, size?, color?, dx?, dy?, family?, bold?, italic?}. Empty text deletes it.
On PdfDocument · module editor · C nexpdf_edit_text
addPageText
doc.addPageText(page: number, json?: string | null): Promise<number>Adds editable page text: {text, x, y (baseline), size, color, family, bold, italic}.
On PdfDocument · module editor · C nexpdf_add_page_text
deleteContent
doc.deleteContent(page: number, id?: string | null): Promise<number>Deletes a text line or an image of the page content.
On PdfDocument · module editor · C nexpdf_delete_content
transformImage
doc.transformImage(page: number, id: string | null, llx: number, lly: number, urx: number, ury: number): Promise<number>Moves or resizes an image to a rectangle (PDF points).
On PdfDocument · module editor · C nexpdf_transform_image
replaceImage
doc.replaceImage(page: number, id: string | null, rgb: string, width: number, height: number): Promise<number>Replaces an image with RGB pixels (width x height x 3 bytes).
On PdfDocument · module editor · C nexpdf_replace_image
editTextBlock
doc.editTextBlock(pageIndex: number, text: string | null, colorHex: string | null, fontSize: number, bold: number, italic: number, replaceExisting: number, llx: number, lly: number, urx: number, ury: number): Promise<number>Writes a text block into a rectangle with colour, size and style, optionally replacing the text already there.
On PdfDocument · module editor · C nexpdf_edit_text_block
Metadata, bookmarks, layers and attachments
metadataJson
doc.metadataJson(): Promise<string>The document information (title, author, subject, keywords, ...) as JSON.
On PdfDocument · always available · C nexpdf_metadata_json
setMetadata
doc.setMetadata(title?: string | null, author?: string | null, subject?: string | null, keywords?: string | null): Promise<number>Sets the title, author, subject and keywords. Omitted (null) values keep the current one.
On PdfDocument · module editor · C nexpdf_set_metadata
outlinesJson
doc.outlinesJson(): Promise<string>The bookmarks as JSON: [{"title","page","children":[...]}].
On PdfDocument · always available · C nexpdf_outlines_json
setOutlinesJson
doc.setOutlinesJson(json?: string | null): Promise<number>Replaces the bookmarks with a JSON tree in the same shape.
On PdfDocument · module editor · C nexpdf_set_outlines_json
pageLabelsJson
doc.pageLabelsJson(): Promise<string>Page labels: {"labels":["i","ii","1"],"ranges":[{"start":0,"style":"roman","prefix":"","first":1}]}.
On PdfDocument · always available · C nexpdf_page_labels_json
setPageLabelsJson
doc.setPageLabelsJson(json?: string | null): Promise<number>Sets the page label ranges ([] removes the labels). Styles: decimal, roman, ROMAN, letters, LETTERS, none.
On PdfDocument · module editor · C nexpdf_set_page_labels_json
layersJson
doc.layersJson(): Promise<string>The optional content groups (layers): [{"num","gen","name","visible","printable"}].
On PdfDocument · always available · C nexpdf_layers_json
setLayerVisible
doc.setLayerVisible(num: number, generation: number, visible: number): Promise<number>Shows or hides a layer.
On PdfDocument · always available · C nexpdf_set_layer_visible
attachmentsJson
doc.attachmentsJson(): Promise<string>The embedded files: [{"name","description","mime","size","page"}]; page is null for document-level files.
On PdfDocument · always available · C nexpdf_attachments_json
attachmentData
doc.attachmentData(name?: string | null): Promise<string>The bytes of an embedded file.
On PdfDocument · always available · C nexpdf_attachment_data
addAttachment
doc.addAttachment(name: string | null, data: string, mime?: string | null, description?: string | null): Promise<number>Embeds a file at document level.
On PdfDocument · module editor · C nexpdf_add_attachment
removeAttachment
doc.removeAttachment(name?: string | null): Promise<number>Removes an embedded file.
On PdfDocument · module editor · C nexpdf_remove_attachment
Encryption, watermarks and stamping
encryptAes256
doc.encryptAes256(userPw?: string | null, ownerPw?: string | null): Promise<number>Encrypts with AES-256 using a user (open) password and an owner password.
On PdfDocument · module security · C nexpdf_encrypt_aes256
encryptWithPermissions
doc.encryptWithPermissions(userPw: string | null, ownerPw: string | null, permissions: number): Promise<number>Encrypts with AES-256 and a permission mask: print 1, modify 2, copy 4, annotate 8, fill forms 16, assemble 32.
On PdfDocument · module security · C nexpdf_encrypt_with_permissions
securityJson
doc.securityJson(): Promise<string>The encryption state: {"encrypted","revision","owner","print","modify","copy","annotate","fill_forms","assemble"}.
On PdfDocument · always available · C nexpdf_security_json
removePassword
doc.removePassword(password?: string | null): Promise<number>Removes the protection. Needs owner access: the document was opened with the owner password, or pass it here.
On PdfDocument · module security · C nexpdf_remove_password
addWatermark
doc.addWatermark(text?: string | null): Promise<number>Stamps a text watermark on every page.
On PdfDocument · module security · C nexpdf_add_watermark
removeWatermarks
doc.removeWatermarks(): Promise<number>Removes the watermarks NexPDF added.
On PdfDocument · module security · C nexpdf_remove_watermarks
addHeaderFooter
doc.addHeaderFooter(header: string | null, footer: string | null, fontSize: number): Promise<number>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 PdfDocument · module security · C nexpdf_add_header_footer
addBates
doc.addBates(prefix: string | null, start: number, digits: number): Promise<number>Adds Bates numbering: prefix, first number and number of digits.
On PdfDocument · module security · C nexpdf_add_bates
Redaction
applyRedaction
doc.applyRedaction(pageIndex: number, llx: number, lly: number, urx: number, ury: number, fillWhite: number): Promise<number>Permanently removes the text, images and annotations under a rectangle and paints an opaque box over it, black or white.
On PdfDocument · module redaction · C nexpdf_apply_redaction
redactMatches
doc.redactMatches(query: string | null, mode: number, fillWhite: number): Promise<number>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 PdfDocument · module redaction · C nexpdf_redact_matches
Digital signatures
signPades
doc.signPades(signer?: string | null, reason?: string | null, location?: string | null): Promise<string>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 PdfDocument · module signatures · C nexpdf_sign_pades
signPkcs12
doc.signPkcs12(p12: string, password?: string | null, optionsJson?: string | null): Promise<string>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 PdfDocument · module signatures · C nexpdf_sign_pkcs12
pkcs12InfoJson
NexPdf.api.pkcs12InfoJson(data: string, password?: string | null): Promise<string>The certificate summary of a PKCS#12 file; fails with "incorrect password" on a wrong password.
On NexPdf.api · module signatures · C nexpdf_pkcs12_info_json
prepareExternalSignature
doc.prepareExternalSignature(cert: string, optionsJson?: string | null): Promise<string>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 PdfDocument · module signatures · C nexpdf_prepare_external_signature
externalSignatureData
NexPdf.api.externalSignatureData(prepared: string, cert: string): Promise<string>External signing, step 2: the bytes to sign (DER signed attributes; sign their SHA-256 on devices that take a digest).
On NexPdf.api · module signatures · C nexpdf_external_signature_data
completeExternalSignature
NexPdf.api.completeExternalSignature(prepared: string, cert: string, signature: string, algorithm: number, optionsJson?: string | null): Promise<string>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.api · module signatures · C nexpdf_complete_external_signature
verifySignaturesJson
NexPdf.api.verifySignaturesJson(data: string): Promise<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.api · always available · C nexpdf_verify_signatures_json
verifySignaturesWithRootsJson
NexPdf.api.verifySignaturesWithRootsJson(data: string, rootsPem?: string | null): Promise<string>Verifies the signatures treating the PEM certificates in roots_pem as trust anchors.
On NexPdf.api · module signatures · C nexpdf_verify_signatures_with_roots_json
addLtv
NexPdf.api.addLtv(data: string): Promise<string>Adds long-term validation data (DSS with OCSP responses and CRLs) to a signed file.
On NexPdf.api · module signatures · C nexpdf_add_ltv
addDocumentTimestamp
doc.addDocumentTimestamp(optionsJson?: string | null): Promise<string>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 PdfDocument · module signatures · C nexpdf_add_document_timestamp
addDocumentTimestampBytes
NexPdf.api.addDocumentTimestampBytes(data: string, optionsJson?: string | null): Promise<string>Adds a document timestamp to the bytes of a PDF file (for example straight from signing). Same options. Returns the new file.
On NexPdf.api · module signatures · C nexpdf_add_document_timestamp_bytes
prepareDocumentTimestamp
doc.prepareDocumentTimestamp(optionsJson?: string | null): Promise<string>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 PdfDocument · module signatures · C nexpdf_prepare_document_timestamp
documentTimestampRequest
NexPdf.api.documentTimestampRequest(prepared: string, hash?: string | null): Promise<string>Document timestamp, step 2: the DER TimeStampReq to send to the TSA as application/timestamp-query (hash SHA-256 by default).
On NexPdf.api · module signatures · C nexpdf_document_timestamp_request
completeDocumentTimestamp
NexPdf.api.completeDocumentTimestamp(prepared: string, token: string): Promise<string>Document timestamp, step 3: the timestamped PDF, from the prepared file and the TSA token (TimeStampResp or TimeStampToken).
On NexPdf.api · module signatures · C nexpdf_complete_document_timestamp
signatureTimestampRequest
NexPdf.api.signatureTimestampRequest(data: string, hash?: string | null): Promise<string>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.api · module signatures · C nexpdf_signature_timestamp_request
addSignatureTimestamp
NexPdf.api.addSignatureTimestamp(data: string, token: string): Promise<string>B-T in steps: stores the TSA answer (TimeStampResp or TimeStampToken) in the last signature, signed bytes unchanged, and returns the PDF.
On NexPdf.api · module signatures · C nexpdf_add_signature_timestamp
ltvRequestsJson
NexPdf.api.ltvRequestsJson(data: string, responsesJson?: string | null): Promise<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.api · module signatures · C nexpdf_ltv_requests_json
addLtvWithResponses
NexPdf.api.addLtvWithResponses(data: string, responsesJson?: string | null): Promise<string>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.api · module signatures · C nexpdf_add_ltv_with_responses
validateLtaJson
NexPdf.api.validateLtaJson(data: string, trustRootsPem?: string | null): Promise<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.api · module signatures · C nexpdf_validate_lta_json
PDF/A, PDF/X and PDF/UA
convertPdfa
doc.convertPdfa(): Promise<number>Converts the document to PDF/A (ISO 19005) for archiving.
On PdfDocument · module standards · C nexpdf_convert_pdfa
convertPdfx
doc.convertPdfx(): Promise<number>Converts the document to PDF/X for print exchange.
On PdfDocument · module standards · C nexpdf_convert_pdfx
autoTag
doc.autoTag(lang: string | null, force: number): Promise<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 PdfDocument · module standards · C nexpdf_auto_tag
validatePdfaJson
doc.validatePdfaJson(level?: string | null): Promise<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 PdfDocument · module standards · C nexpdf_validate_pdfa_json
validatePdfuaJson
doc.validatePdfuaJson(): Promise<string>PDF/UA validation (PDF/UA-1, or PDF/UA-2 when declared), with the same report as PDF/A validation.
On PdfDocument · module standards · C nexpdf_validate_pdfua_json
convertPdfaLevel
doc.convertPdfaLevel(level?: string | null): Promise<number>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 PdfDocument · module standards · C nexpdf_convert_pdfa_level
convertPdfaJson
doc.convertPdfaJson(level: string | null, flattenDpi: number, substituteFonts: number): Promise<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 PdfDocument · module standards · C nexpdf_convert_pdfa_json
convertPdfuaJson
doc.convertPdfuaJson(part: number, lang?: string | null): Promise<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 PdfDocument · module standards · C nexpdf_convert_pdfua_json
validatePdfuaPartJson
doc.validatePdfuaPartJson(part: number): Promise<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 PdfDocument · module standards · C nexpdf_validate_pdfua_part_json
registerSubstituteFont
NexPdf.api.registerSubstituteFont(data: string): Promise<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.api · module standards · C nexpdf_register_substitute_font
OCR
ocr
doc.ocr(optionsJson?: string | null): Promise<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 PdfDocument · module ocr · C nexpdf_ocr
ocrLoadModel
NexPdf.api.ocrLoadModel(optionsJson: string | null, model: string, dictionary?: string | null): Promise<number>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.api · module ocr · C nexpdf_ocr_load_model
ocrModelsJson
NexPdf.api.ocrModelsJson(): Promise<string>The loaded OCR models: kind, name, languages, symbols, size.
On NexPdf.api · module ocr · C nexpdf_ocr_models_json
ocrUnloadModels
NexPdf.api.ocrUnloadModels(languages?: string | null): Promise<number>Unloads the OCR models of the given languages (all when empty). Returns the number removed.
On NexPdf.api · module ocr · C nexpdf_ocr_unload_models
Compare, optimise and memory
compareJson
doc.compareJson(b: PdfDocument, dpi: number): Promise<string>Compares two documents (text and visual differences per page) at the given resolution, as JSON.
On PdfDocument · always available · C nexpdf_compare_json
compareOverlayPng
doc.compareOverlayPng(b: PdfDocument, pageIndex: number, dpi: number): Promise<string>A PNG overlay of the visual differences of one page of two documents.
On PdfDocument · always available · C nexpdf_compare_overlay_png
optimize
doc.optimize(): Promise<string>Optimises the document (removes unused objects, recompresses streams); returns a JSON report.
On PdfDocument · module editor · C nexpdf_optimize
subsetFonts
doc.subsetFonts(): Promise<string>Subsets the embedded fonts to the glyphs the document uses; returns a JSON report.
On PdfDocument · module editor · C nexpdf_subset_fonts
trimMemory
doc.trimMemory(): Promise<number>Drops cached data of the document; returns the bytes freed.
On PdfDocument · always available · C nexpdf_trim_memory
memoryUsageBytes
doc.memoryUsageBytes(): Promise<number>Approximate memory used by the document, in bytes.
On PdfDocument · always available · C nexpdf_memory_usage_bytes
compareTextJson
doc.compareTextJson(b: PdfDocument, optionsJson?: string | null): Promise<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 PdfDocument · always available · C nexpdf_compare_text_json
compareAnnotate
doc.compareAnnotate(b: PdfDocument, optionsJson?: string | null): Promise<string>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 PdfDocument · always available · C nexpdf_compare_annotate
Other
setAnnotationFlags
doc.setAnnotationFlags(num: number, generation: number, flagsJson?: string | null): Promise<number>On PdfDocument
setAnnotationStyle
doc.setAnnotationStyle(num: number, generation: number, styleJson?: string | null): Promise<number>On PdfDocument