NexPDF for Java
Render, extract, edit, convert, sign and validate PDFs from Java 17+ with the NexPDF engine through JNA.
NexPDF for Java (com.nexdevit:nexpdf) calls the native NexPDF engine through JNA. Every function of
the C ABI is available. Functions that take a document are methods of NexPdfDocument; the others
are static methods of NexPdf. Options and results are the same JSON strings as in every NexPDF SDK.
import com.nexdevit.nexpdf.*;
import java.nio.file.Path;
try (NexPdfDocument doc = NexPdfDocument.open(Path.of("contract.pdf"))) {
System.out.println(doc.pageCount() + " pages");
System.out.println(doc.extractPageText(0));
}Android apps use the Android SDK, which bundles the library and a JNI layer.
Requirements
| Java | 17 or later |
| Operating systems | Linux (x86_64, arm64), macOS (Apple silicon and Intel), Windows (x86_64) |
| Native library | libnexpdf_ffi.so, libnexpdf_ffi.dylib or nexpdf_ffi.dll from the release, or packed in the jar |
| Dependencies | net.java.dev.jna:jna (brought in by the package) |
How it works
NexPdfDocumentimplementsAutoCloseable: close it with try-with-resources. An unreachable document is freed by aCleaner; using a closed document throwsIllegalStateException.- Failures throw the unchecked
NexPdfExceptionwith the engine's message. A rejected license key setscode()to the negative license code. size_tparameters (page indices) arelong,uint32_tareint, byte buffersbyte[], page listsint[].nullpasses NULL for optional strings.- Use one document from one thread at a time. Different documents can be used on different threads,
and
doc.copy()gives an independent copy.
Getting started
Installation
Gradle or Maven, and where the native library goes.
Your first document
Open a PDF, render a page and extract its text.
Add your license key
Activate a key and handle license errors.
Running without a key
View-only mode, the watermark and trial keys.
Guides
Opening and saving
Files, bytes, passwords, pictures, HTML and Office input.
Rendering
Pages and thumbnails to PNG, coordinates.
Document structure
Metadata, bookmarks, page labels, layers, attachments.
Text extraction
Text, Markdown, positioned blocks, passages for LLMs.
Search
Find text and its rectangles.
OCR
Make scanned pages searchable, in any script.
Structured extraction
Tables, key-values, schema extraction with your LLM, classification.
Barcodes
Read QR, Data Matrix, PDF417 and linear codes; draw barcodes.
Annotations
Markup, shapes, ink, stamps, measurements, XFDF.
Forms
Fill, create, calculate, flatten, import and export.
XFA forms
Run FormCalc and JavaScript, lay out dynamic forms, convert to AcroForm, flatten.
Comment threads
Replies and review states on annotations.
Real-time collaboration
Sync pages, annotations, comments, form values and bookmarks.
Editing
Merge, split, reorder, crop; edit text and images.
Compare and optimise
Diff versions, shrink files, control memory.
Word-level comparison
Inserted, deleted, replaced and moved text; annotated PDF.
Security
Encryption, permissions, watermarks, Bates numbers.
Redaction
Remove content for good by area, text or pattern.
Signatures
PAdES signing, external signers, verification.
Long-term signatures
PAdES B-LTA, document and archive timestamps.
Conversion
PDF to Word, Excel, PowerPoint, HTML and more.
Templates
PDFs from Word, HTML and PDF templates and JSON data.
PDF/A, PDF/X and PDF/UA
Archiving, print and accessibility.
PDF/A and PDF/UA validation
PDF/A and PDF/UA-1 and -2 with clause ids; convert to PDF/A or PDF/UA.