First ,
I use different computers to open the same word, and the pictures are inconsistent。
The correct display is △,The wrong display is “口”
I think it’s a problem with fonts, but I copied fonts(c:/windows/fonts) from a computer that was OK to open to another computer, and it still didn’t work.
Second,
I convert this doc to html,The display is ‘V’,and it does not prompt font warning information.
My code is as follows,Even if I use ‘setFontsFolder’, the result is the same
Document doc = new Document("/Users/zhengkai/Documents/other/1.docx");
HtmlSaveOptions nop = new HtmlSaveOptions();
nop.setEncoding(Charset.forName("UTF-8"));
nop.setExportImagesAsBase64(true);
FontSubstitutionWarningCollector callback = new FontSubstitutionWarningCollector();
doc.setWarningCallback(callback);
FontSettings fontsettings = FontSettings.getDefaultInstance();
// fontsettings.setFontsFolder("/Users/zhengkai/Documents/other/fonts", true);
doc.setFontSettings(fontsettings);
doc.save("/Users/zhengkai/Documents/other/1.html");
callback.printMissingFontDetails();
private static class FontSubstitutionWarningCollector implements IWarningCallback {
public ArrayList<String> listOfFonts = new ArrayList<String>();
public void warning(WarningInfo info) {
// if (info.getWarningType() == WarningType.FONT_SUBSTITUTION || info.getWarningType() == WarningType.FONT_EMBEDDING) {
if (!listOfFonts.contains(info.getDescription()))
listOfFonts.add(info.getDescription());
// }
}
public void printMissingFontDetails() {
for (int i = 0; i < listOfFonts.size(); i++)
System.out.println(listOfFonts.get(i).toString());
}
}
1.docx (13.8 KB)
word’s correct display in computerA.png (1.0 KB)
word’s wrong display in computerB.png (551 Bytes)
image in aspose convert word to html.png (592 Bytes)