We are seeing some formatting issues while converting documents on a Unix environment. Windows environment seems to be fine, however the same pdf logic conversion running on our Unix version seems to have some issues with font formatting.
We do not see any bold letting and some of the index numbering is in a bigger font.
We can save a docx4j created document as a pdf using Word and it all looks good.
When we run our application on Windows to convert the docx document to PDF it looks good.
When we run our application on Unix to convert the docx document to PDF, we have the issues.
Is there some special font mapping we need to address for Unix system?
Using docx4j latest nightly build.
Using Plutext-Enterprise.jar 3.1.0
Windows 7
Unix JDK Oracle 1.6.0_20
The PDF conversion logic is as follows.
// Font regex (optional)
// Set regex if you want to restrict to some defined subset of fonts
// Here we have to do this before calling createContent,
// since that discovers fonts
// String regex = null;
// Windows:
String regex = ".*(calibri|cour|arial|times|comic|georgia|impact|LSANS|pala|tahoma|trebuc|verdana|symbol|webdings|wingding).*";
PhysicalFonts.setRegex(regex);
// Document loading (required)
// Set up font mapper (optional)
Mapper fontMapper = new IdentityPlusMapper();
try {
wordMLPackage.setFontMapper(fontMapper);
} catch (Exception e) {
e.printStackTrace();
}
// .. example of mapping missing font Algerian to installed font
// Comic
// Sans MS
PhysicalFont font = PhysicalFonts.getPhysicalFonts().get(
"Times New Roman");
fontMapper.getFontMappings().put("Calibri", font);
String tempFilename = DIR_OUT + "ConvertDocumentToPDF-" + DocxUtil.getFormattedDateTextForFileName();
FOSettings foSettings = Docx4J.createFOSettings();
if (saveFO) {
String foFile = tempFilename + ".fo";
foSettings.setFoDumpFile(new java.io.File(foFile));
}
foSettings.setWmlPackage(wordMLPackage);
// exporter writes to an OutputStream.
try {
String outputFile = tempFilename + ".pdf";
OutputStream os = new java.io.FileOutputStream(outputFile);
// Don't care what type of exporter you use
Docx4J.toFO(foSettings, os, Docx4J.FLAG_NONE);
Thanks