API reference
Every class, method and function of the NexPDF Go SDK, grouped by feature. Generated from NexPDF 1.1.0.
Generated from NexPDF 1.1.0
This page is generated from the sources of github.com/nexdevit/nexpdf-go. It lists 190 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
Error
type Error struct { Message string; Code int32 }The error returned by every call: the engine message and, from ActivateLicense, the negative license code.
On package nexpdf
Version
func Version() stringVersion returns the engine version.
On package nexpdf
ActivateLicense
func ActivateLicense(keyOrXML, platform, appID string) (int32, error)ActivateLicense activates a license key or license.xml once per process. It returns 2 (licensed) or 1 (trial); other results are returned as *Error with the negative code. Without a license the SDK is view-only and rendered pages carry a watermark.
On package nexpdf
IsLicensed
func IsLicensed(module string) boolIsLicensed reports whether the active license unlocks module (annotations, forms, editor, security, redaction, signatures, conversion, ocr, standards).
On package nexpdf
OpenBytes
func OpenBytes(data []byte, password ...string) (*Document, error)OpenBytes opens a PDF (or a JPEG/PNG/TIFF picture) from bytes; Word, Excel and PowerPoint files, EPUB / FictionBook / XPS books and CBZ comics are converted. A non-empty password opens encrypted files.
On package nexpdf
Open
func Open(path string, password ...string) (*Document, error)Open reads and opens a file; see OpenBytes.
On package nexpdf
Close
func (d *Document) Close()Close frees the native document. It is safe to call more than once.
On Document
Save
func (d *Document) Save(path string, linearized bool) errorSave writes the document to path; linearized writes a "Fast Web View" file.
On Document
Copy
func (d *Document) Copy() (*Document, error)Copy returns an independent copy (for undo snapshots or work in another goroutine).
On Document
Library and licensing
LicenseStatusJSON
func LicenseStatusJSON() (string, error)The active license as JSON: state (unlicensed, trial or licensed), licensee, id, tier, modules, expires_at, days_left and watermark.
On package nexpdf · always available · C nexpdf_license_status_json
Invoke
func Invoke(requestJson string) (string, error)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 package nexpdf · always available · C nexpdf_invoke
RegisterStandardFont
func RegisterStandardFont(data []byte) (int32, error)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 package nexpdf · always available · C nexpdf_register_standard_font
HasBundledFonts
func HasBundledFonts() (int32, error)1 when the Liberation fonts are compiled in, 0 in the lighter builds.
On package nexpdf · always available · C nexpdf_has_bundled_fonts
Opening and saving
OpenBytesWithPassword
func OpenBytesWithPassword(data []byte, password string) (*Document, error)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 package nexpdf · always available · C nexpdf_open_bytes_with_password
FromHTML
func FromHTML(html string) (*Document, error)Lays out HTML as a new PDF document.
On package nexpdf · module conversion · C nexpdf_from_html
OpenOffice
func OpenOffice(data []byte) (*Document, error)Converts Word, Excel or PowerPoint bytes (format detected) to a new PDF document.
On package nexpdf · module conversion · C nexpdf_open_office
OpenEbook
func OpenEbook(data []byte) (*Document, error)Converts EPUB, FictionBook (.fb2, .fb2.zip), XPS/OpenXPS or a CBZ comic archive to a new PDF document.
On package nexpdf · module conversion · C nexpdf_open_ebook
OpenImage
func OpenImage(data []byte) (*Document, error)Converts JPEG, PNG or TIFF bytes to a new PDF, one page per picture.
On package nexpdf · always available · C nexpdf_open_image
SaveBytes
func (d *Document) SaveBytes() ([]byte, error)The document, with every change, as PDF bytes (full rewrite).
On Document · always available · C nexpdf_save_bytes
SaveLinearized
func (d *Document) SaveLinearized() ([]byte, error)A linearized ("Fast Web View") PDF: the first page shows before the download ends.
On Document · always available · C nexpdf_save_linearized
Pages and rendering
PageCount
func (d *Document) PageCount() (int32, error)Number of pages.
On Document · always available · C nexpdf_page_count
PageWidth
func (d *Document) PageWidth(pageIndex int) float64Displayed page width in points (crop box, rotation and /UserUnit applied).
On Document · always available · C nexpdf_page_width
PageHeight
func (d *Document) PageHeight(pageIndex int) float64Displayed page height in points (crop box, rotation and /UserUnit applied).
On Document · always available · C nexpdf_page_height
PageViewJSON
func (d *Document) PageViewJSON(pageIndex int) (string, error)How the page is displayed: width, height, rotation, user_unit, crop and the PDF-to-display matrix to_display.
On Document · always available · C nexpdf_page_view_json
RenderPagePNG
func (d *Document) RenderPagePNG(pageIndex int, dpi float64) ([]byte, error)Renders a page to PNG at the given resolution (dots per inch). Unlicensed and trial renders carry a watermark.
On Document · always available · C nexpdf_render_page_png
RenderThumbPNG
func (d *Document) RenderThumbPNG(pageIndex int, maxDim uint32) ([]byte, error)Renders a thumbnail PNG whose longer side is at most max_dim pixels.
On Document · always available · C nexpdf_render_thumb_png
SetOverprint
func (d *Document) SetOverprint(mode int32) (int32, error)Overprint simulation for later renders: 0 = PDF/X documents only (default), 1 = always, 2 = never.
On Document · always available · C nexpdf_set_overprint
Text, search and assistant
ExtractPageText
func (d *Document) ExtractPageText(pageIndex int) (string, error)The text of a page in reading order.
On Document · always available · C nexpdf_extract_page_text
ExtractMarkdown
func (d *Document) ExtractMarkdown() (string, error)The whole document as Markdown (headings, lists, tables).
On Document · always available · C nexpdf_extract_markdown
SearchJSON
func (d *Document) SearchJSON(query string) (string, error)Finds a text in every page (case-insensitive). Returns a JSON array of hits: page, context and the rectangle llx, lly, urx, ury in PDF points.
On Document · always available · C nexpdf_search_json
PageBlocksJSON
func (d *Document) PageBlocksJSON(pageIndex int) (string, error)The text blocks of a page as JSON: text, font size and the rectangle llx, lly, urx, ury.
On Document · always available · C nexpdf_page_blocks_json
AskDocument
func (d *Document) AskDocument(question string, k uint32, maxChars uint32) (string, error)Document assistant retrieval, offline (BM25): the k passages most relevant to a question and a page-tagged context of at most max_chars characters (0 = 200000) to send to a language model. Returns {"passages":[{"page","text","score"}],"context":"...","context_pages":[...]}.
On Document · always available · C nexpdf_ask_document
PageWordsJSON
func (d *Document) PageWordsJSON(pageIndex int, optionsJson string) (string, error)The words of a page with exact boxes from the glyph widths and the text state: text, bbox, quad (follows rotated text), font, size, angle, line. {"glyphs":true} adds the glyph boxes.
On Document · always available · C nexpdf_page_words_json
Conversion
ToHTML
func (d *Document) ToHTML() (string, error)The document as HTML.
On Document · module conversion · C nexpdf_to_html
ToJSON
func (d *Document) ToJSON() (string, error)The document content as JSON.
On Document · module conversion · C nexpdf_to_json
ToXML
func (d *Document) ToXML() (string, error)The document content as XML.
On Document · module conversion · C nexpdf_to_xml
ToCSV
func (d *Document) ToCSV() (string, error)Tables of the document as CSV.
On Document · module conversion · C nexpdf_to_csv
ToRTF
func (d *Document) ToRTF() (string, error)The document as RTF.
On Document · module conversion · C nexpdf_to_rtf
ToDOCX
func (d *Document) ToDOCX() ([]byte, error)The document as a Word (.docx) file.
On Document · module conversion · C nexpdf_to_docx
ToXLSX
func (d *Document) ToXLSX() ([]byte, error)The document as an Excel workbook, one sheet per page.
On Document · module conversion · C nexpdf_to_xlsx
ToPPTX
func (d *Document) ToPPTX() ([]byte, error)The document as a PowerPoint presentation, one slide per page.
On Document · module conversion · C nexpdf_to_pptx
ToReflowHTML
func (d *Document) ToReflowHTML(optionsJson string) (string, error)The text as responsive HTML for small screens. Options (may be omitted): {"pages":[0],"images":true,"full_page":true,"title":"..."}.
On Document · module conversion · C nexpdf_to_reflow_html
OpenXLSXWithClock
func OpenXLSXWithClock(data []byte, clockUnixSeconds float64) (*Document, error)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 package nexpdf · module conversion · C nexpdf_open_xlsx_with_clock
OpenDOCXWithOptionsJSON
func OpenDOCXWithOptionsJSON(data []byte, optionsJson string) (*Document, error)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 package nexpdf · module conversion · C nexpdf_open_docx_with_options_json
Templates
TemplateDOCXToPdf
func TemplateDOCXToPdf(templateBytes []byte, dataJson string, optionsJson string) (*Document, error)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 package nexpdf · module conversion · C nexpdf_template_docx_to_pdf
TemplateDOCXFill
func TemplateDOCXFill(templateBytes []byte, dataJson string) ([]byte, error)Fills a Word template with JSON data and returns the new .docx bytes.
On package nexpdf · module conversion · C nexpdf_template_docx_fill
TemplateHTMLToPdf
func TemplateHTMLToPdf(htmlUtf8 string, dataJson string, optionsJson string) (*Document, error)Fills an HTML template with JSON data (values HTML-escaped, {{{raw}}} not) and lays it out as a new PDF document.
On package nexpdf · module conversion · C nexpdf_template_html_to_pdf
TemplateFillPdf
func (d *Document) TemplateFillPdf(dataJson string, optionsJson string) (int32, error)Fills a PDF template in place: AcroForm fields by name and placeholders in the page text. Options {"flatten","fields","text","strict","locale"}. Returns the number of fields and text lines filled.
On Document · module conversion · C nexpdf_template_fill_pdf
TemplateDOCXFillWith
func TemplateDOCXFillWith(templateBytes []byte, dataJson string, optionsJson string) ([]byte, error)Fills a Word template with JSON data and options {"strict","locale"}, and returns the new .docx bytes.
On package nexpdf · module conversion · C nexpdf_template_docx_fill_with
Office editing
XLSXEdit
func XLSXEdit(data []byte, editsJson string) ([]byte, error)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 package nexpdf · module conversion · C nexpdf_xlsx_edit
XLSXCellsJSON
func XLSXCellsJSON(data []byte, optionsJson string) (string, error)The cells of an Excel workbook as JSON: per sheet, each cell with its type, value and formula. Options {"sheet","range","recalculate"}.
On package nexpdf · module conversion · C nexpdf_xlsx_cells_json
DOCXEdit
func DOCXEdit(data []byte, opsJson string) ([]byte, error)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 package nexpdf · module conversion · C nexpdf_docx_edit
DOCXParagraphsJSON
func DOCXParagraphsJSON(data []byte) (string, error)The paragraphs of a Word document as JSON: index, style, text and whether each is in a table.
On package nexpdf · module conversion · C nexpdf_docx_paragraphs_json
Structured extraction and barcodes
ExtractTablesJSON
func (d *Document) ExtractTablesJSON(pageIndex int32, optionsJson string) (string, error)Ruled and unruled tables of a page (every page when the index is negative) with cells, spans, CSV and Markdown. Options {"ruled","unruled","min_unruled_lines"}.
On Document · module conversion · C nexpdf_extract_tables_json
ExtractKeyValuesJSON
func (d *Document) ExtractKeyValuesJSON(optionsJson string) (string, error)Label/value pairs from the layout and typed entities (dates, amounts, IBANs, e-mails, phones, VAT numbers) with normalised values. Options {"pages","date_order"}.
On Document · module conversion · C nexpdf_extract_key_values_json
ExtractionPromptJSON
func (d *Document) ExtractionPromptJSON(schemaJson string, optionsJson string) (string, error)A prompt (system, prompt, response_schema) for extracting a JSON schema with the language model of your choice. The engine makes no network calls.
On Document · module conversion · C nexpdf_extraction_prompt_json
ExtractionValidateJSON
func (d *Document) ExtractionValidateJSON(schemaJson string, answerJson string) (string, error)Validates and coerces a model answer against the schema and grounds each value on the pages: valid, value, errors, warnings, fields.
On Document · module conversion · C nexpdf_extraction_validate_json
ClassifyDocumentJSON
func (d *Document) ClassifyDocumentJSON(labelsJson string) (string, error)Classifies the document into one of the given labels by keywords, with scores and a prompt for LLM classification.
On Document · module conversion · C nexpdf_classify_document_json
ReadBarcodesJSON
func (d *Document) ReadBarcodesJSON(pageIndex int32, optionsJson string) (string, error)Reads the barcodes of a page (every page when the index is negative): QR, Data Matrix, Aztec, PDF417, Code 128/39/93, EAN/UPC, ITF, Codabar and more, with positions in PDF points.
On Document · module conversion · C nexpdf_read_barcodes_json
ReadBarcodesImageJSON
func ReadBarcodesImageJSON(data []byte, optionsJson string) (string, error)Reads the barcodes of a PNG or JPEG image, with positions in pixels.
On package nexpdf · module conversion · C nexpdf_read_barcodes_image_json
AddBarcode
func (d *Document) AddBarcode(pageIndex int, llx float64, lly float64, urx float64, ury float64, format string, text string) (int32, error)Draws text as a vector barcode (white background, quiet zone) into a rectangle of a page, in PDF points.
On Document · module editor · C nexpdf_add_barcode
AddBarcodeEx
func (d *Document) AddBarcodeEx(pageIndex int, llx float64, lly float64, urx float64, ury float64, format string, text string, optionsJson string) (int32, error)Draws a vector barcode with options {"human_readable":"auto"|"always"|"never","quiet_zone","background","color"}; auto prints the digits under EAN and UPC codes.
On Document · module editor · C nexpdf_add_barcode_ex
Annotations
AddAnnotation
func (d *Document) AddAnnotation(pageIndex int, kind string, colorHex string, opacity float64, contents string, llx float64, lly float64, urx float64, ury float64) (int32, error)Adds an annotation. kind is a PDF annotation subtype such as Highlight, Underline, StrikeOut, Squiggly, Square, Circle, FreeText or Text; text markup is fitted to the lines under the rectangle. Colour is #RRGGBB, the rectangle is in PDF points.
On Document · module annotations · C nexpdf_add_annotation
AddInk
func (d *Document) AddInk(pageIndex int, colorHex string, strokeWidth float64, opacity float64, coords string) (int32, error)Adds a freehand ink annotation. coords is "x,y;x,y;..." in PDF points.
On Document · module annotations · C nexpdf_add_ink
AddLine
func (d *Document) AddLine(pageIndex int, kind string, colorHex string, opacity float64, strokeWidth float64, x1 float64, y1 float64, x2 float64, y2 float64) (int32, error)Adds a line or arrow (kind is Line or Arrow) from (x1, y1) to (x2, y2) in PDF points.
On Document · module annotations · C nexpdf_add_line
AnnotationsJSON
func (d *Document) AnnotationsJSON(pageIndex int) (string, error)The annotations of a page as JSON: num, gen, kind, color, contents and the rectangle.
On Document · always available · C nexpdf_annotations_json
RemoveAnnotation
func (d *Document) RemoveAnnotation(pageIndex int, num uint32, generation uint16) (int32, error)Removes the annotation with object number num and generation gen from a page.
On Document · module annotations · C nexpdf_remove_annotation
MoveAnnotation
func (d *Document) MoveAnnotation(num uint32, generation uint16, dx float64, dy float64) (int32, error)Moves an annotation by (dx, dy) PDF points.
On Document · module annotations · C nexpdf_move_annotation
SetAnnotationContents
func (d *Document) SetAnnotationContents(num uint32, generation uint16, contents string) (int32, error)Replaces the text contents of an annotation.
On Document · module annotations · C nexpdf_set_annotation_contents
ExportXFDF
func (d *Document) ExportXFDF() (string, error)Exports every annotation as an XFDF document.
On Document · module annotations · C nexpdf_export_xfdf
ImportXFDF
func (d *Document) ImportXFDF(xfdf string) (int32, error)Imports annotations from an XFDF document.
On Document · module annotations · C nexpdf_import_xfdf
FlattenAnnotations
func (d *Document) FlattenAnnotations(pageIndex int32) (int32, error)Burns annotations into the page content. A negative page index flattens every page.
On Document · module annotations · C nexpdf_flatten_annotations
AddImageStamp
func (d *Document) AddImageStamp(page int, llx float64, lly float64, urx float64, ury float64, rgba []byte, width uint32, height uint32, opacity float64) (int32, error)Adds a picture stamp annotation from RGBA pixels (transparency kept). 1 on success.
On Document · module annotations · C nexpdf_add_image_stamp
AddMeasurement
func (d *Document) AddMeasurement(page int, json string) (string, error)Stores a measurement: {"kind":"distance|perimeter|area","points":[[x,y],...],"unit":"mm","per_point":0.3528,"label":"1:100","color":"#2f54d6"}. Returns {"num","gen","value","text"}.
On Document · module annotations · C nexpdf_add_measurement
MeasurementsJSON
func (d *Document) MeasurementsJSON() (string, error)The stored measurements as JSON.
On Document · always available · C nexpdf_measurements_json
AddFileAttachmentAnnot
func (d *Document) AddFileAttachmentAnnot(pageIndex int, x float64, y float64, name string, data []byte, mime string, description string) (int32, error)Adds a paperclip annotation carrying a file; (x, y) is the top-left corner of the icon in PDF points.
On Document · module annotations · C nexpdf_add_file_attachment_annot
AddInkSignature
func (d *Document) AddInkSignature(pageIndex int, colorHex string, strokeWidth float64, strokes string) (int32, error)Adds a handwritten signature: an ink annotation with several strokes ("x,y;x,y|x,y;x,y", PDF points) and subject "Signature". Visual only; use a PAdES signature for a cryptographic one.
On Document · module annotations · C nexpdf_add_ink_signature
ReplyToAnnotation
func (d *Document) ReplyToAnnotation(pageIndex int, num uint32, generation uint16, author string, text string) (int32, error)Adds a reply by author to an annotation (or to another reply). Returns the reply object number (generation 0).
On Document · module annotations · C nexpdf_reply_to_annotation
AnnotationRepliesJSON
func (d *Document) AnnotationRepliesJSON(pageIndex int, num uint32, generation uint16) (string, error)The thread under an annotation, oldest first: num, gen, in_reply_to, author, date, text, state, state_model.
On Document · module annotations · C nexpdf_annotation_replies_json
SetAnnotationState
func (d *Document) SetAnnotationState(pageIndex int, num uint32, generation uint16, author string, state string) (int32, error)Sets a review state (Accepted, Rejected, Cancelled, Completed, None) or marked state (Marked, Unmarked) as a hidden state reply. Returns its object number.
On Document · module annotations · C nexpdf_set_annotation_state
Forms
FormFieldsJSON
func (d *Document) FormFieldsJSON() (string, error)The form fields as JSON: name, kind, value, page, rectangle, read_only and required.
On Document · module forms · C nexpdf_form_fields_json
FillFormField
func (d *Document) FillFormField(name string, value string) (int32, error)Sets a field value as a viewer would: the keystroke and validate scripts check the value, then every calculated field is recomputed. Check boxes take "true" or "false", list fields the option text.
On Document · module forms · C nexpdf_fill_form_field
SetSignatureAppearance
func (d *Document) SetSignatureAppearance(name string, rgba []byte, width uint32, height uint32) (int32, error)Shows a drawn, typed or scanned signature (RGBA pixels) in a signature field without signing digitally; scaled to fit each widget and centred. A later digital signature replaces it.
On Document · module forms · C nexpdf_set_signature_appearance
AddFormField
func (d *Document) AddFormField(pageIndex int, kind string, name string, llx float64, lly float64, urx float64, ury float64) (int32, error)Adds a form field named name in a rectangle of a page. kind: text (default), checkbox, radio, combobox, listbox, button, signature or barcode.
On Document · module forms · C nexpdf_add_form_field
FlattenForms
func (d *Document) FlattenForms() (int32, error)Burns the form fields into the page content.
On Document · module forms · C nexpdf_flatten_forms
RecalculateForms
func (d *Document) RecalculateForms() (int32, error)Runs every calculate script; returns how many fields changed.
On Document · module forms · C nexpdf_recalculate_forms
ExportFormJSON
func (d *Document) ExportFormJSON() (string, error)The field values as a JSON object.
On Document · module forms · C nexpdf_export_form_json
ImportFormJSON
func (d *Document) ImportFormJSON(json string) (int32, error)Fills fields from a JSON object of names and values.
On Document · module forms · C nexpdf_import_form_json
ExportFormFDF
func (d *Document) ExportFormFDF(pdfName string) ([]byte, error)The field values as an FDF file; pdf_name is the file name recorded in it.
On Document · module forms · C nexpdf_export_form_fdf
ImportFormFDF
func (d *Document) ImportFormFDF(data []byte) (int32, error)Fills fields from an FDF file.
On Document · module forms · C nexpdf_import_form_fdf
ExportFormXFDF
func (d *Document) ExportFormXFDF(pdfName string) (string, error)The field values as XFDF.
On Document · module forms · C nexpdf_export_form_xfdf
ImportFormXFDF
func (d *Document) ImportFormXFDF(xfdf string) (int32, error)Fills fields from XFDF.
On Document · module forms · C nexpdf_import_form_xfdf
XFA forms
XfaInfoJSON
func (d *Document) XfaInfoJSON() (string, error)Whether the document has XFA, whether it is dynamic, field and data counts and the XDP packets.
On Document · module forms · C nexpdf_xfa_info_json
XfaExportData
func (d *Document) XfaExportData(format string) (string, error)The XFA data as xml (default) or flat json ({"path":"value"}). Fails when the document has no XFA.
On Document · module forms · C nexpdf_xfa_export_data
XfaImportData
func (d *Document) XfaImportData(data string, format string) (int32, error)Imports XFA data: XML replaces the data, JSON sets the given values. Static forms get their AcroForm fields updated. Returns the number of values imported.
On Document · module forms · C nexpdf_xfa_import_data
XfaToAcroform
func (d *Document) XfaToAcroform() (int32, error)Converts to a plain AcroForm PDF and removes XFA; dynamic forms are laid out into new pages and scripts run first. Text fields keep their formatted display value as /V. Returns the number of AcroForm fields.
On Document · module forms · C nexpdf_xfa_to_acroform
XfaFlatten
func (d *Document) XfaFlatten() (int32, error)Converts and flattens the XFA form: a plain PDF with the values drawn. Returns the number of flattened widgets.
On Document · module forms · C nexpdf_xfa_flatten
XfaRemove
func (d *Document) XfaRemove() (int32, error)Removes XFA and keeps the AcroForm fields and pages: 1 removed, 0 no XFA.
On Document · module forms · C nexpdf_xfa_remove
XfaToAcroformJSON
func (d *Document) XfaToAcroformJSON(optionsJson string) (string, error)Converts to AcroForm with options {"scripts":true,"flatten":false} and returns a report: flattened, fields, pages, warnings and validation_errors (som, test, severity, message).
On Document · module forms · C nexpdf_xfa_to_acroform_json
XfaRunScriptsJSON
func (d *Document) XfaRunScriptsJSON() (string, error)Runs the initialize, calculate and validate scripts (FormCalc and JavaScript) and stores calculated values in the data: data_changed, warnings, validation_errors.
On Document · module forms · C nexpdf_xfa_run_scripts_json
RegisterFallbackFont
func RegisterFallbackFont(data []byte) (int32, error)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 package nexpdf · module forms · C nexpdf_register_fallback_font
Real-time collaboration
SyncExportJSON
func (d *Document) SyncExportJSON(sinceVersion uint64) (string, error)NexPDF Sync: every change (from any client) with a Lamport clock above since_version, as a nexpdf-sync/1 change set.
On Document · module annotations · C nexpdf_sync_export_json
SyncExportLocalJSON
func (d *Document) SyncExportLocalJSON(sinceVersion uint64) (string, error)NexPDF Sync: only this copy's own changes above since_version (what a client pushes); keep the returned clock for the next call.
On Document · module annotations · C nexpdf_sync_export_local_json
SyncApplyJSON
func (d *Document) SyncApplyJSON(changesJson string) (string, error)NexPDF Sync: applies remote changes, last writer wins per record. Returns ok, clock, applied, ignored, conflicts and errors.
On Document · module annotations · C nexpdf_sync_apply_json
SyncSnapshotJSON
func (d *Document) SyncSnapshotJSON() (string, error)NexPDF Sync: every record with its version, base records and tombstones included.
On Document · module annotations · C nexpdf_sync_snapshot_json
SyncSetClientId
func (d *Document) SyncSetClientId(clientId string) (int32, error)NexPDF Sync: the client id this copy versions its changes under (1 to 64 characters of [A-Za-z0-9-_.:@]).
On Document · module annotations · C nexpdf_sync_set_client_id
Page editing
RotatePage
func (d *Document) RotatePage(pageIndex int, degrees int32) (int32, error)Rotates a page by a multiple of 90 degrees.
On Document · module editor · C nexpdf_rotate_page
DeletePage
func (d *Document) DeletePage(pageIndex int) (int32, error)Deletes a page.
On Document · module editor · C nexpdf_delete_page
DuplicatePage
func (d *Document) DuplicatePage(pageIndex int) (int32, error)Inserts a copy of a page after it.
On Document · module editor · C nexpdf_duplicate_page
AddBlankPage
func (d *Document) AddBlankPage() (int32, error)Appends a blank page.
On Document · module editor · C nexpdf_add_blank_page
ReversePages
func (d *Document) ReversePages() (int32, error)Reverses the page order.
On Document · module editor · C nexpdf_reverse_pages
MovePage
func (d *Document) MovePage(from int, to int) (int32, error)Moves the page at from to index to.
On Document · module editor · C nexpdf_move_page
CropPage
func (d *Document) CropPage(pageIndex int, llx float64, lly float64, urx float64, ury float64) (int32, error)Sets the crop box of a page (PDF points).
On Document · module editor · C nexpdf_crop_page
ExtractPages
func (d *Document) ExtractPages(indices []uint32) (*Document, error)A new document made of the given pages (split).
On Document · module editor · C nexpdf_extract_pages
AppendDocument
func (d *Document) AppendDocument(other *Document) (int32, error)Appends the pages of another document (merge).
On Document · module editor · C nexpdf_append_document
InsertImagePages
func (d *Document) InsertImagePages(index int, data []byte) (int32, error)Inserts the pictures of a JPEG, PNG or TIFF file as pages before index (clamped; the page count appends). Returns the number of pages added.
On Document · always available · C nexpdf_insert_image_pages
SetPageBackground
func (d *Document) SetPageBackground(optionsJson string, rgb []byte, width uint32, height uint32) (int32, error)Sets a page background: a colour and/or an RGB picture. Options: {"color":"#fbf4e2","fit":"cover|stretch|center","scale":1,"opacity":1,"pages":[]}. Returns the pages changed.
On Document · module editor · C nexpdf_set_page_background
RemovePageBackground
func (d *Document) RemovePageBackground(pagesJson string) (int32, error)Removes NexPDF backgrounds from the pages in pages_json ("[0,2]"), or from every page.
On Document · module editor · C nexpdf_remove_page_background
Content editing
PageContentJSON
func (d *Document) PageContentJSON(page int) (string, error)The text lines and images of a page as JSON: id, kind (text or image), text, rect, size, color, font, family, bold, italic. Ids stay valid until the next edit of that page.
On Document · module editor · C nexpdf_page_content_json
EditText
func (d *Document) EditText(page int, id string, changeJson string) (int32, error)Edits a text line: {text?, size?, color?, dx?, dy?, family?, bold?, italic?}. Empty text deletes it.
On Document · module editor · C nexpdf_edit_text
AddPageText
func (d *Document) AddPageText(page int, json string) (int32, error)Adds editable page text: {text, x, y (baseline), size, color, family, bold, italic}.
On Document · module editor · C nexpdf_add_page_text
DeleteContent
func (d *Document) DeleteContent(page int, id string) (int32, error)Deletes a text line or an image of the page content.
On Document · module editor · C nexpdf_delete_content
TransformImage
func (d *Document) TransformImage(page int, id string, llx float64, lly float64, urx float64, ury float64) (int32, error)Moves or resizes an image to a rectangle (PDF points).
On Document · module editor · C nexpdf_transform_image
ReplaceImage
func (d *Document) ReplaceImage(page int, id string, rgb []byte, width uint32, height uint32) (int32, error)Replaces an image with RGB pixels (width x height x 3 bytes).
On Document · module editor · C nexpdf_replace_image
EditTextBlock
func (d *Document) EditTextBlock(pageIndex int, text string, colorHex string, fontSize float64, bold int32, italic int32, replaceExisting int32, llx float64, lly float64, urx float64, ury float64) (int32, error)Writes a text block into a rectangle with colour, size and style, optionally replacing the text already there.
On Document · module editor · C nexpdf_edit_text_block
Metadata, bookmarks, layers and attachments
MetadataJSON
func (d *Document) MetadataJSON() (string, error)The document information (title, author, subject, keywords, ...) as JSON.
On Document · always available · C nexpdf_metadata_json
SetMetadata
func (d *Document) SetMetadata(title string, author string, subject string, keywords string) (int32, error)Sets the title, author, subject and keywords. Omitted (null) values keep the current one.
On Document · module editor · C nexpdf_set_metadata
OutlinesJSON
func (d *Document) OutlinesJSON() (string, error)The bookmarks as JSON: [{"title","page","children":[...]}].
On Document · always available · C nexpdf_outlines_json
SetOutlinesJSON
func (d *Document) SetOutlinesJSON(json string) (int32, error)Replaces the bookmarks with a JSON tree in the same shape.
On Document · module editor · C nexpdf_set_outlines_json
PageLabelsJSON
func (d *Document) PageLabelsJSON() (string, error)Page labels: {"labels":["i","ii","1"],"ranges":[{"start":0,"style":"roman","prefix":"","first":1}]}.
On Document · always available · C nexpdf_page_labels_json
SetPageLabelsJSON
func (d *Document) SetPageLabelsJSON(json string) (int32, error)Sets the page label ranges ([] removes the labels). Styles: decimal, roman, ROMAN, letters, LETTERS, none.
On Document · module editor · C nexpdf_set_page_labels_json
LayersJSON
func (d *Document) LayersJSON() (string, error)The optional content groups (layers): [{"num","gen","name","visible","printable"}].
On Document · always available · C nexpdf_layers_json
SetLayerVisible
func (d *Document) SetLayerVisible(num uint32, generation uint16, visible int32) (int32, error)Shows or hides a layer.
On Document · always available · C nexpdf_set_layer_visible
AttachmentsJSON
func (d *Document) AttachmentsJSON() (string, error)The embedded files: [{"name","description","mime","size","page"}]; page is null for document-level files.
On Document · always available · C nexpdf_attachments_json
AttachmentData
func (d *Document) AttachmentData(name string) ([]byte, error)The bytes of an embedded file.
On Document · always available · C nexpdf_attachment_data
AddAttachment
func (d *Document) AddAttachment(name string, data []byte, mime string, description string) (int32, error)Embeds a file at document level.
On Document · module editor · C nexpdf_add_attachment
RemoveAttachment
func (d *Document) RemoveAttachment(name string) (int32, error)Removes an embedded file.
On Document · module editor · C nexpdf_remove_attachment
Encryption, watermarks and stamping
EncryptAES256
func (d *Document) EncryptAES256(userPw string, ownerPw string) (int32, error)Encrypts with AES-256 using a user (open) password and an owner password.
On Document · module security · C nexpdf_encrypt_aes256
EncryptWithPermissions
func (d *Document) EncryptWithPermissions(userPw string, ownerPw string, permissions uint32) (int32, error)Encrypts with AES-256 and a permission mask: print 1, modify 2, copy 4, annotate 8, fill forms 16, assemble 32.
On Document · module security · C nexpdf_encrypt_with_permissions
SecurityJSON
func (d *Document) SecurityJSON() (string, error)The encryption state: {"encrypted","revision","owner","print","modify","copy","annotate","fill_forms","assemble"}.
On Document · always available · C nexpdf_security_json
RemovePassword
func (d *Document) RemovePassword(password string) (int32, error)Removes the protection. Needs owner access: the document was opened with the owner password, or pass it here.
On Document · module security · C nexpdf_remove_password
AddWatermark
func (d *Document) AddWatermark(text string) (int32, error)Stamps a text watermark on every page.
On Document · module security · C nexpdf_add_watermark
RemoveWatermarks
func (d *Document) RemoveWatermarks() (int32, error)Removes the watermarks NexPDF added.
On Document · module security · C nexpdf_remove_watermarks
AddHeaderFooter
func (d *Document) AddHeaderFooter(header string, footer string, fontSize float64) (int32, error)Adds a header and/or footer to every page. {page} and {total} are replaced; a font size of 0 or less uses the default.
On Document · module security · C nexpdf_add_header_footer
AddBates
func (d *Document) AddBates(prefix string, start uint64, digits uint32) (int32, error)Adds Bates numbering: prefix, first number and number of digits.
On Document · module security · C nexpdf_add_bates
Redaction
ApplyRedaction
func (d *Document) ApplyRedaction(pageIndex int, llx float64, lly float64, urx float64, ury float64, fillWhite int32) (int32, error)Permanently removes the text, images and annotations under a rectangle and paints an opaque box over it, black or white.
On Document · module redaction · C nexpdf_apply_redaction
RedactMatches
func (d *Document) RedactMatches(query string, mode int32, fillWhite int32) (int32, error)Finds and permanently redacts every match. mode: 0 = text, 1 = regular expression, 2 = pattern id (email, phone, credit-card, iban, pt-nif, us-ssn, ipv4, url, date). Returns the number of areas redacted.
On Document · module redaction · C nexpdf_redact_matches
Digital signatures
SignPAdES
func (d *Document) SignPAdES(signer string, reason string, location string) ([]byte, error)Signs with a new self-signed test certificate (PAdES B-B) and returns the signed file. Write the bytes as they are: saving the document again breaks the signature.
On Document · module signatures · C nexpdf_sign_pades
SignPKCS12
func (d *Document) SignPKCS12(p12 []byte, password string, optionsJson string) ([]byte, error)Signs with a PKCS#12 (.p12/.pfx) identity and returns the signed file. Options: {"name","reason","location","contact","field","tsa_url","ltv":true,"appearance":{"page":0,"rect":[llx,lly,urx,ury],"ink":"x,y;x,y|...","text":"..."}}. Without a .p12 a self-signed certificate is created.
On Document · module signatures · C nexpdf_sign_pkcs12
PKCS12InfoJSON
func PKCS12InfoJSON(data []byte, password string) (string, error)The certificate summary of a PKCS#12 file; fails with "incorrect password" on a wrong password.
On package nexpdf · module signatures · C nexpdf_pkcs12_info_json
PrepareExternalSignature
func (d *Document) PrepareExternalSignature(cert []byte, optionsJson string) ([]byte, error)External signing (HSM, smart card, cloud KMS), step 1: a PDF with an empty signature for the signer certificate (PEM or DER, optionally followed by its chain). Options as for PKCS#12 signing.
On Document · module signatures · C nexpdf_prepare_external_signature
ExternalSignatureData
func ExternalSignatureData(prepared []byte, cert []byte) ([]byte, error)External signing, step 2: the bytes to sign (DER signed attributes; sign their SHA-256 on devices that take a digest).
On package nexpdf · module signatures · C nexpdf_external_signature_data
CompleteExternalSignature
func CompleteExternalSignature(prepared []byte, cert []byte, signature []byte, algorithm int32, optionsJson string) ([]byte, error)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 package nexpdf · module signatures · C nexpdf_complete_external_signature
VerifySignaturesJSON
func VerifySignaturesJSON(data []byte) (string, error)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 package nexpdf · always available · C nexpdf_verify_signatures_json
VerifySignaturesWithRootsJSON
func VerifySignaturesWithRootsJSON(data []byte, rootsPem string) (string, error)Verifies the signatures treating the PEM certificates in roots_pem as trust anchors.
On package nexpdf · module signatures · C nexpdf_verify_signatures_with_roots_json
AddLTV
func AddLTV(data []byte) ([]byte, error)Adds long-term validation data (DSS with OCSP responses and CRLs) to a signed file.
On package nexpdf · module signatures · C nexpdf_add_ltv
AddDocumentTimestamp
func (d *Document) AddDocumentTimestamp(optionsJson string) ([]byte, error)Adds an RFC 3161 document timestamp from a TSA (PAdES B-LTA). Options: {"tsa_url" (required),"hash","field","reserved","ltv"}; with ltv the validation data of earlier signatures goes into the DSS first. Returns the new file.
On Document · module signatures · C nexpdf_add_document_timestamp
AddDocumentTimestampBytes
func AddDocumentTimestampBytes(data []byte, optionsJson string) ([]byte, error)Adds a document timestamp to the bytes of a PDF file (for example straight from signing). Same options. Returns the new file.
On package nexpdf · module signatures · C nexpdf_add_document_timestamp_bytes
PrepareDocumentTimestamp
func (d *Document) PrepareDocumentTimestamp(optionsJson string) ([]byte, error)Document timestamp from your own TSA or HSM, step 1: the PDF with an empty timestamp (options as for adding one, without tsa_url).
On Document · module signatures · C nexpdf_prepare_document_timestamp
DocumentTimestampRequest
func DocumentTimestampRequest(prepared []byte, hash string) ([]byte, error)Document timestamp, step 2: the DER TimeStampReq to send to the TSA as application/timestamp-query (hash SHA-256 by default).
On package nexpdf · module signatures · C nexpdf_document_timestamp_request
CompleteDocumentTimestamp
func CompleteDocumentTimestamp(prepared []byte, token []byte) ([]byte, error)Document timestamp, step 3: the timestamped PDF, from the prepared file and the TSA token (TimeStampResp or TimeStampToken).
On package nexpdf · module signatures · C nexpdf_complete_document_timestamp
SignatureTimestampRequest
func SignatureTimestampRequest(data []byte, hash string) ([]byte, error)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 package nexpdf · module signatures · C nexpdf_signature_timestamp_request
AddSignatureTimestamp
func AddSignatureTimestamp(data []byte, token []byte) ([]byte, error)B-T in steps: stores the TSA answer (TimeStampResp or TimeStampToken) in the last signature, signed bytes unchanged, and returns the PDF.
On package nexpdf · module signatures · C nexpdf_add_signature_timestamp
LTVRequestsJSON
func LTVRequestsJSON(data []byte, responsesJson string) (string, error)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 package nexpdf · module signatures · C nexpdf_ltv_requests_json
AddLTVWithResponses
func AddLTVWithResponses(data []byte, responsesJson string) ([]byte, error)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 package nexpdf · module signatures · C nexpdf_add_ltv_with_responses
ValidateLtaJSON
func ValidateLtaJSON(data []byte, trustRootsPem string) (string, error)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 package nexpdf · module signatures · C nexpdf_validate_lta_json
PDF/A, PDF/X and PDF/UA
ConvertPDFA
func (d *Document) ConvertPDFA() (int32, error)Converts the document to PDF/A (ISO 19005) for archiving.
On Document · module standards · C nexpdf_convert_pdfa
ConvertPDFX
func (d *Document) ConvertPDFX() (int32, error)Converts the document to PDF/X for print exchange.
On Document · module standards · C nexpdf_convert_pdfx
AutoTag
func (d *Document) AutoTag(lang string, force int32) (string, error)Tags the document for accessibility (PDF/UA structure tree, language, title, metadata). lang is a BCP 47 tag (default en-US); force re-tags a document that is already tagged. Returns a JSON report.
On Document · module standards · C nexpdf_auto_tag
ValidatePDFAJSON
func (d *Document) ValidatePDFAJSON(level string) (string, error)Rule-based PDF/A validation for 1a to 4f (the declared level, or 2b, when empty): compliant, level and failures with clause, message, page and object.
On Document · module standards · C nexpdf_validate_pdfa_json
ValidatePdfuaJSON
func (d *Document) ValidatePdfuaJSON() (string, error)PDF/UA validation (PDF/UA-1, or PDF/UA-2 when declared), with the same report as PDF/A validation.
On Document · module standards · C nexpdf_validate_pdfua_json
ConvertPDFALevel
func (d *Document) ConvertPDFALevel(level string) (int32, error)Converts to a chosen PDF/A level (2b when empty); level A tags the document first. 1 when the result validates; otherwise the error lists the clauses still failing.
On Document · module standards · C nexpdf_convert_pdfa_level
ConvertPDFAJSON
func (d *Document) ConvertPDFAJSON(level string, flattenDpi float64, substituteFonts int32) (string, error)Converts to a PDF/A level (1a to 4f, 2b when empty) and returns the report: level, compliant, fixed, substitutions and remaining. flatten_dpi is the resolution PDF/A-1 transparency is flattened at (300 when 0 or less); substitute_fonts 0 leaves non-embedded fonts alone.
On Document · module standards · C nexpdf_convert_pdfa_json
ConvertPdfuaJSON
func (d *Document) ConvertPdfuaJSON(part int32, lang string) (string, error)Converts to PDF/UA-1 or PDF/UA-2 (part 1 or 2): tags an untagged document, embeds fonts and, for part 2, uses the PDF 2.0 namespaces. lang (en-US when empty) applies when the document has none. Returns profile, compliant, fixed, warnings, substitutions, remaining.
On Document · module standards · C nexpdf_convert_pdfua_json
ValidatePdfuaPartJSON
func (d *Document) ValidatePdfuaPartJSON(part int32) (string, error)Validates against PDF/UA-1 or PDF/UA-2 (part 1 or 2) whatever the document declares, with the same report as PDF/UA validation.
On Document · module standards · C nexpdf_validate_pdfua_part_json
RegisterSubstituteFont
func RegisterSubstituteFont(data []byte) (string, error)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 package nexpdf · module standards · C nexpdf_register_substitute_font
OCR
OCR
func (d *Document) OCR(optionsJson string) (string, error)Recognises scanned pages and adds an invisible, searchable text layer. Options (may be omitted): {"engine":"auto|builtin|tesseract|neural","languages":"por+eng","dpi":300,"pages":[0],"force":false}. Returns a JSON report.
On Document · module ocr · C nexpdf_ocr
OCRLoadModel
func OCRLoadModel(optionsJson string, model []byte, dictionary string) (int32, error)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 package nexpdf · module ocr · C nexpdf_ocr_load_model
OCRModelsJSON
func OCRModelsJSON() (string, error)The loaded OCR models: kind, name, languages, symbols, size.
On package nexpdf · module ocr · C nexpdf_ocr_models_json
OCRUnloadModels
func OCRUnloadModels(languages string) (int32, error)Unloads the OCR models of the given languages (all when empty). Returns the number removed.
On package nexpdf · module ocr · C nexpdf_ocr_unload_models
Compare, optimise and memory
CompareJSON
func (d *Document) CompareJSON(b *Document, dpi float64) (string, error)Compares two documents (text and visual differences per page) at the given resolution, as JSON.
On Document · always available · C nexpdf_compare_json
CompareOverlayPNG
func (d *Document) CompareOverlayPNG(b *Document, pageIndex int, dpi float64) ([]byte, error)A PNG overlay of the visual differences of one page of two documents.
On Document · always available · C nexpdf_compare_overlay_png
Optimize
func (d *Document) Optimize() (string, error)Optimises the document (removes unused objects, recompresses streams); returns a JSON report.
On Document · module editor · C nexpdf_optimize
SubsetFonts
func (d *Document) SubsetFonts() (string, error)Subsets the embedded fonts to the glyphs the document uses; returns a JSON report.
On Document · module editor · C nexpdf_subset_fonts
TrimMemory
func (d *Document) TrimMemory() intDrops cached data of the document; returns the bytes freed.
On Document · always available · C nexpdf_trim_memory
MemoryUsageBytes
func (d *Document) MemoryUsageBytes() intApproximate memory used by the document, in bytes.
On Document · always available · C nexpdf_memory_usage_bytes
CompareTextJSON
func (d *Document) CompareTextJSON(b *Document, optionsJson string) (string, error)Word-level text comparison of two documents: inserted, deleted, replaced and moved text with positions, and a summary. Options {"ignore_case","ignore_punctuation","detect_moves","min_move_words","align","page_map"}.
On Document · always available · C nexpdf_compare_text_json
CompareAnnotate
func (d *Document) CompareAnnotate(b *Document, optionsJson string) ([]byte, error)The word-level comparison as a new PDF with highlight annotations (deleted red, inserted green, moved blue). Options add output, author and the colours.
On Document · always available · C nexpdf_compare_annotate
Other
SetAnnotationFlags
func (d *Document) SetAnnotationFlags(num uint32, generation uint16, flagsJson string) (int32, error)Annotation flags (/F). flags_json: {"readonly":true,"print":false} changes only the flags it names; ["print","locked"] sets exactly these; a number is the bitmask. Names: invisible, hidden, print, nozoom, norotate, noview, readonly, locked, togglenoview, lockedcontents. XFDF import and export keep them (flags="print,readonly"). 1 on success.
On Document
SetAnnotationStyle
func (d *Document) SetAnnotationStyle(num uint32, generation uint16, styleJson string) (int32, error)Colour, opacity and border width, then a new appearance: {"color":"#RRGGBB","opacity":0.5, "border_width":2}, every key optional (a missing key keeps the current value). 1 on success.
On Document