In version v2016R1, it is possible to customize jOfficeConvert to either embed or not embed fonts in the output PDF document converted from Microsoft Word.

Option to Embed Fonts
Embedding fonts is the default option in jOfficeConvert starting in version v2016R1. It is important to define a fall back font to be used in case a font can not be found on the operating system. Using a sophisticated embedded font matching logic, jOfficeConvert will first try and identify a substitute font among the local or user defined fonts. The fall back font is only used for embedding when no acceptable font was found among the user fonts or the system fonts. Embedded fonts are sub-setted to only include the characters included in the document to minimize the size of the ouput PDFs.

// Create an object to store the conversion options
WordConvertOptions opts = new WordConvertOptions();
 
// Set option to embed fonts to true
opts.setEmbedded(true);
 
// Suggested Fallback Font for Windows with Microsoft Office
opts.setFallbackFontPath("C:/Windows/Fonts/ARIALUNI.ttf");
 
// Suggested Fallback Font for Mac OS X 
opts.setFallbackFontPath("/Library/Fonts/Arial Unicode.ttf");
 
// 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");
 
// Open / Convert the Word Document using the conversion options
WordDocument converter = new WordDocument("C:/input.doc", options);
 
// Convert and save as PDF
converter.saveAsPDF("C:/out.pdf");

About the FallBack Font
As shown in the sample code above, when choosing the option to embed font, you can specify a fallback font to be used in case no matching fonts are found on the machine using the font matching logic.

Option to Not Embed Fonts
Choosing to not embed fonts will create smaller PDF files but these files may not render the same or render well on machines that are missing the fonts referenced in them. Even though fonts are not embedded in the PDF file, local fonts will be used to determine metrics and layout in the document. Fonts will be identified using the non-embedded font matching logic.

// Create options
WordConvertOptions opts = new WordConvertOptions();
 
// Set option to embed fonts to false
opts.setEmbedded(false);
 
// Open the Word Document and pass on the options
WordDocument converter = new WordDocument("C:/input.doc", options);
 
// Convert and save as PDF
converter.saveAsPDF("C:/out.pdf");
Tagged: