Custom Path for libPDFNetC.so

Product: PDFNet
Product Version: 10.2.0
Platform: Oracle Linux 8

Hi,
Recently we are upgrading our server to oracle linux 8 and we dont have execute permission on /tmp folder. But PDFNet tries to execute libPDFNetC.so from /tmp folder. We dont want to change java -Djava.io.tmpdir as this options will change the /tmp folder as a whole. Is there any way can load and execute libPDFNetC.so from any custom directory?

Hi Imran,

I understand that you’re looking to reference the Apryse SDK’s libPDFNetC.so file from a custom directory, however, you should be able to reference this dependency from a directory of your choosing. I would recommend using the Java-specific library for Linux found on our website, which should bundle the required .so file into the PDFNetC .jar file so that you may reference the libraries from anywhere you have permission to execute from.

Take a look at “Integrate into your application” section in the aforementioned “Getting Started” guide for Java on our website that covers compiling & executing your application using the lib & classpath location of your choosing.

Please feel free to reach out if you have any further questions or issues while using the Apryse SDK – our team would be happy to help!

Thanks,
Kaden Rettig
Associate Technical Support Engineer
Apryse Support

Hi kaden,
We are already exploring the procedure you are referenced but still we are facing the issue. Let me share sample file and necessary error for your reference.

  • Main.java file
import com.pdftron.pdf.PDFNet;

/**
 * @author al.imran
 * @since 2/22/23
 */
public class Main {

    public static void main(String[] args) {
        PDFNet.initialize("LICENSE_KEY");

        System.out.println("Hello World!");
    }

}
  • Terminal Error
alimran@alimran-laptop:~/Desktop/itext/src/main/java$ javac -cp .:/usr/local/pdftron/PDFNet-10.2.0.jar Main.java 
alimran@alimran-laptop:~/Desktop/itext/src/main/java$ java -cp .:/usr/local/pdftron/PDFNet-10.2.0.jar Main 
Exception in thread "main" java.lang.UnsatisfiedLinkError: /tmp/NativeLib13285533393718/libPDFNetC.so: /tmp/NativeLib13285533393718/libPDFNetC.so: failed to map segment from shared object
	at java.lang.ClassLoader$NativeLibrary.load(Native Method)
	at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1937)
	at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1820)
	at java.lang.Runtime.load0(Runtime.java:782)
	at java.lang.System.load(System.java:1098)
	at com.pdftron.pdf.NativeLoader.loadLibraryFromJar(NativeLoader.java:87)
	at com.pdftron.pdf.PDFNet.<clinit>(PDFNet.java:19)
	at Main.main(Main.java:19)
alimran@alimran-laptop:~/Desktop/itext/src/main/java$ 

Hi Imran,

I noticed that you are using Maven in your current implementation with Gradle. If you are facing this issue while using these build automation tools, and you are unable to alter the Java tmp directory, I would recommend modifying your existing application or creating a new project that uses manual integration of dependencies to see if this would be a better fit for your requirements.
Please take a look at the following link to our website and ensure that the “Manual Integration” tab is selected for the corresponding directions: https://docs.apryse.com/core/guides/get-started/java/#integrate-into-your-application

Thank you,
Kaden Rettig
Associate Technical Support Engineer
Apryse Support