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?

1 Like

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

1 Like

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$ 

1 Like

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

1 Like

Hi Kaden,
I am using manual integration in above cases and there is no dependency on maven or gradle. Can you closely look into my terminal commands?

1 Like

Hi Imran,

I have tested these same commands as you listed from your terminal on a local test project using the latest version of the available PDFNet Java SDK for Linux and was not able to replicate the error you’re seeing here regarding the libPDFNetC.so file. It appears the issue may still be related to your current configuration.

I would recommend downloading the Java-specific PDFNet SDK for Linux that is available from the downloads page on our website or the guide that I previously mentioned and compiling using the PDFNet.jar that is provided therein.

Thank you,
Kaden Rettig
Associate Technical Support Engineer
Apryse Support Team

1 Like

Hi Kaden,
Please make sure you have noexec permission on your /tmp folder. I am using my dev machine which is running on ubuntu 22.04.5 LTS.

alimran@alimran-laptop:/$ sudo mount -t tmpfs -o noexec tmpfs /tmp
alimran@alimran-laptop:/$ findmnt -T /tmp
TARGET SOURCE FSTYPE OPTIONS
/tmp   tmpfs  tmpfs  rw,noexec,relatime,inode64
alimran@alimran-laptop:/$

By executing above command you can have noexec permission on your /tmp folder. Now Run my previous reply command and check if you can replicate the issue.

1 Like

Hi Imran,

I appreciate your patience in this matter. I was able to reproduce this issue you’re seeing - after investigation, I found a system property specific to PDFNet that you can set to accomplish your intended use case without altering the java.io.tempdir. This system property is called com.pdftron.systemloadtmpdir and can be used in the same way as java.io.tmpdir.

I created an extended forum FAQ post regarding this topic with more details that you can find here. Please take a look and let me know if you have any additional questions!

Thank you,
Kaden Rettig
Associate Technical Support Engineer
Apryse Support Team

1 Like

Hi Kaden,
With updated version you have mentioned it is now working. Thanks.

2 Likes

Imran,

I am glad to hear it - thank you for letting me know. If you happen to have any other issues or questions regarding the Apryse SDK, please feel free to create a new topic or submit a ticket here.

Thank you,
Kaden Rettig
Associate Technical Support Engineer
Apryse Support Team

1 Like