Skip to Content
NexPDF

Installation

Add the NexPDF Java package with Gradle or Maven and make the native engine library available to JNA.

English

Add the dependency

build.gradle.kts
dependencies {
    implementation("com.nexdevit:nexpdf:1.1.0")
}

The package depends on net.java.dev.jna:jna, which your build tool brings in.

Get the native library

Download the archive for your platform from the v1.1.0 release:

PlatformArchiveLibrary
Linux x86_64nexpdf-ffi-1.1.0-linux-x64.tar.gzlib/libnexpdf_ffi.so
Linux arm64nexpdf-ffi-1.1.0-linux-arm64.tar.gzlib/libnexpdf_ffi.so
macOSnexpdf-ffi-1.1.0-macos-universal.tar.gzlib/libnexpdf_ffi.dylib
Windows x86_64nexpdf-ffi-1.1.0-windows-x64.ziplib/nexpdf_ffi.dll

Tell JNA where the library is

JNA finds libnexpdf_ffi through, in this order:

  1. the system property -Dnexpdf.library.path=<file> or the NEXPDF_LIB_PATH environment variable (the full path of the file);
  2. jna.library.path (a folder);
  3. the system library path;
  4. the jar itself, under <platform>/ resources.
java -Dnexpdf.library.path=/opt/nexpdf/lib/libnexpdf_ffi.so -jar app.jar

Check the installation

System.out.println(com.nexdevit.nexpdf.NexPdf.version());

One jar for every platform

JNA loads libraries from the class path under a folder named after the platform. Put the libraries in src/main/resources/ of your application (or of a build of the SDK) before building the jar:

The macOS release library is universal, so the same file goes in both darwin- folders.

Docker

Dockerfile
FROM eclipse-temurin:21-jre
ADD https://github.com/nexdevit/nexpdf-java/releases/download/v1.1.0/nexpdf-ffi-1.1.0-linux-x64.tar.gz /tmp/
RUN tar -xzf /tmp/nexpdf-ffi-1.1.0-linux-x64.tar.gz -C /opt
ENV NEXPDF_LIB_PATH=/opt/nexpdf-ffi-1.1.0-linux-x64/lib/libnexpdf_ffi.so
COPY app.jar /app.jar
CMD ["java", "-jar", "/app.jar"]

On this page