When running our library jOfficeConvert to convert Word, Excel or PowerPoint documents to PDF, some of the Microsoft Windows fonts may be missing on the machine when running on Linux or Unix servers. We have done some research to identify good substitution fonts and have implemented a mechanism to specify font substitutes within our library.

The suggested font substitutions below are meant to offer possible metric compatible font substitutions for Microsoft fonts. These fonts are specifically designed to be metric compatible with their corresponding Microsoft fonts. The substitutions used here are based on information from this webpage: https://wiki.archlinux.org/index.php/Metric-compatible_fonts

Note: the sample is above is showing how to set replacement font when converting Word to PDF but it can be easily edited to set replacement fonts when converting from Excel to PDF or converting PowerPoint to PDF.

// This Java Sample Program Converts a Word Document to PDF
// Using the specified substitute fonts if the Microsoft Office fonts are not found on the machine
// create a new instance of WordConvertOtions
WordConvertOptions options = new WordConvertOptions();
// assign any substitutions using the font family names
//Microsoft Office Fonts
// false indicate that the substitution only happens if the original font is not found on the machine
options.setFontSubstitute("Calibri", "Carlito", false);
options.setFontSubstitute("Cambria", "Caladea", false);
options.setFontSubstitute("Symbol", "SymbolNeu", false);
//Other common Microsoft fonts
options.setFontSubstitute("Arial", "Liberation Sans", false);
options.setFontSubstitute("Times New Roman", "Liberation Serif", false);
options.setFontSubstitute("Symbol", "SymbolNeu", false);
options.setFontSubstitute("Arial Narrow", "Liberation Sans Narrow", false);
options.setFontSubstitute("Georgia", "Gelasio", false);
options.setFontSubstitute("Wingdings", "URWDings", false);			
// Load the document with the options instance
WordDocument wd = new WordDocument("input.doc", options);
// Save the document as a PDF file

You can either install these fonts on your Linux machine directly or add the font files to a folder and make that folder accessible to jOfficeConvert during font discovery using the following static method:

WordDocument.setUserFontDirectories(List dirs);