When converting a Word document to PDF using Qoppa’s PDF library jOfficeConvert, sometimes a font specified in the Word document may not be available on the machine. See our matching logic to identify a matching font. jOfficeConvert will then use the fallback font if one was set.
Fallback Font Error
You will see an error reading:
Error embedding font for Arial, 1 Fallback font not specified
You will see this error only when the option to embed fonts is set to true (this is the default option).
Choosing not to set a fallback font
If the fidelity of converted PDF documents is very important to you, then you will want to leave the fallback font unset (or set to null). This ensures that jOfficeConvert will throw a WordException for any font that cannot be found. You can then make sure to review the documents that fail and install any missing fonts when they are not available on the machine (making sure that the fonts are embeddable) or change the fonts in the original Word documents with fonts that are present on the machine.
Choosing to set a fallback font
If you are dealing with pretty standard Word documents and are more concerned about the successful conversion of the documents, you should set a fallback font.
How to Choose a FallBack Font
The perfect fallback font will contain every character for every world language script.
DroidSansFallbackFull Font has characters for most (but not all) scripts. jOfficeConvert Sample / Demo application includes this font. SansDroid is released under the Apache 2.0 license. When running in an application, you can ship with this font. When running on a well-known server, you can install this font on the machine.
Code2000 Font contains a very wide range of characters and can be found on the Internet for download.
Using Operating System Fonts
You can also decide to use fonts that are present on your operating system. Windows and OS X operating systems include the Arial Unicode Font which contains characters for more scripts.
Sample code showing how to set a fallback font
On a Windows machine
// Create an object to store the conversion options WordConvertOptions opts = new WordConvertOptions(); // Suggested Fallback Font for Windows with Microsoft Office opts.setFallbackFontPath("C:/Windows/Fonts/ARIALUNI.ttf");
On a Mac OS X machine
// Create an object to store the conversion options WordConvertOptions opts = new WordConvertOptions(); // Suggested Fallback Font for Mac OS X opts.setFallbackFontPath("/Library/Fonts/Arial Unicode.ttf");
On a Linux machine (or any platform, really)
// Create an object to store the conversion options WordConvertOptions opts = new WordConvertOptions(); // Suggested Fallback Font for Linux // SansDroid is released under the Apache 2.0 license // and can be used on other platforms as well opts.setFallbackFontPath("/usr/share/fonts/truetype/droid/DroidSansFallbackFull.ttf");
Our sample demo application for jOfficeConvert ships with the Droid Sans font, which can be found under the “fonts” folder under the demo application installation folder. You can copy this font under the “usr/share/fonts/truetype/droid” and make the call above.