We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

TextStamp throws NullPointerException when ran on Linux Server

So the code I am currently working with works fine when I run it on a windows environment. However I have built it to run on an Oracle Linux server and that is where I started running into issues. After debugging I noticed it was throwing the error when it called

TextStamp textStamp = new TextStamp(“Test Text”);

At first the error was Font Helvetica not found. After I got the font path working appropriately (or at least I think I did) it has now just started throwing NullPointerExceptions and I have no idea what is causing this issue. I also found that calling
FormattedText test = new FormattedText(“Test Text”);
is throwing the same error I have a feeling it may still have something to do with the fonts but I am not really sure what to do. I don’t know if you need any other parts of my code, but if you do I will be happy to re-post those portions.

Hi Cody,

Thanks for your inquiry. The mentioned error issue arises with Non-Windows OS(Linux/MAC) due to the font folder path setting. Please set font folder as following before any operation. Hopefully it will help you to resolve the issue.

You can use following methods to get system folder of fonts or set font path to font folders. Hopefully it will help you to fix the issue.

Document.getLocalFontPath () - shows the system folder in which project will look for fonts.
Document.setLocalFontPath (String) - Setting font path to custom folder

//adding a new font path<o:p></o:p>

String path = “c:\fonts\”;<o:p></o:p>


Moreover please also check following code snippet to set font path if there are more than one font path.

//geting the list for standard font directories in different OS<o:p></o:p>

java.util.List list = com.aspose.pdf.Document.getLocalFontPaths();<o:p></o:p>

//seting the user list for standard font directories<o:p></o:p>




//Restoring list for standard font directories by default.<o:p></o:p>


<o:p> </o:p>

<o:p>Please feel free to contact us for any further assistance.</o:p>


<o:p>Best Regards,</o:p>