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

Free Support Forum - aspose.com

Getting an error loading Microsoft fonts on a linux system

we are getting the following error when trying to create a pdf. we are not specifiying the font and while things work well on a windows system we get the following error intermittantly on a linux system

9:12:19.000 AM
2016-02-09 09:12:19 ERROR Scheduler-Default-2#517(BuyerInvoicePDFJobType:306498891) BuyerInvoicePDFJob.executeTransaction:145 exception occured... class com.aspose.pdf.internal.ms.System.z9: Some font was not found. Please check if your font path is present in Document.getLocalFontPath() if not - add it with Document.addLocalFontPath(string)
com.aspose.pdf.internal.p49.z3.m1(Unknown Source)

 class com.aspose.pdf.internal.ms.System.z9: Some font was not found

Can you tell me where to get the font it is requesting?

Hi Mark,

Thanks for your inquiry. Please note on non-Windows OSs Aspose.Pdf for Java looks fonts in system default font path. For Example in case of CentOS it looks fonts in /usr/share/fonts/. I have installed Microsoft fonts on the CentOS and these fonts are installed in system default font path i.e. /usr/share/fonts/msttcorefonts/.

It seems Aspose.Pdf for Java is unable to find fonts on your system. Can you please install Microsoft fonts on your system or copy fonts from your windows OS and paste to your system default font path, and try the conversion again? Hopefully it will resolve the issue.

We are sorry for the inconvenience caused.

Best Regards,

Oddly, my code that creates the pdf does not make any calls for any specific font. can you tell me what font from the windows system it is looking for?

Hi Mark,

Can you please share the code snippet which you are using so that we can test the scenario in our environment. As it will help us in replicating the issue in our environment.

Also please share the version of Linux and JDK you are using.

Hi Mark,

I am sorry for any confusion. I meant Aspose.Pdf for Java is unable to find any font on your system, so suggested your to either install Microsoft fonts (mscorefonts) or copy some fonts from your windows machine to your system default font path. Further more if you want to use fonts form some your custom folder then you need to add that folder path into LocalFontPath as following. You can use following methods to get system folder of fonts or set font path to font folders.

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

// Set font folder path
String path = “/home/tilal/fonts/”;
// Adding a single font directory
// com.aspose.pdf.Document.addLocalFontPath(path);

// setting the user list for standard font directories
java.util.List list = com.aspose.pdf.Document.getLocalFontPaths();

Best Regards,