Installation
Add the NexPDF Java package with Gradle or Maven and make the native engine library available to JNA.
Add the dependency
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:
| Platform | Archive | Library |
|---|---|---|
| Linux x86_64 | nexpdf-ffi-1.1.0-linux-x64.tar.gz | lib/libnexpdf_ffi.so |
| Linux arm64 | nexpdf-ffi-1.1.0-linux-arm64.tar.gz | lib/libnexpdf_ffi.so |
| macOS | nexpdf-ffi-1.1.0-macos-universal.tar.gz | lib/libnexpdf_ffi.dylib |
| Windows x86_64 | nexpdf-ffi-1.1.0-windows-x64.zip | lib/nexpdf_ffi.dll |
Tell JNA where the library is
JNA finds libnexpdf_ffi through, in this order:
- the system property
-Dnexpdf.library.path=<file>or theNEXPDF_LIB_PATHenvironment variable (the full path of the file); jna.library.path(a folder);- the system library path;
- the jar itself, under
<platform>/resources.
java -Dnexpdf.library.path=/opt/nexpdf/lib/libnexpdf_ffi.so -jar app.jarCheck 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
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"]