image1.pdf (51.8 KB)
16.zip (36.1 KB)
16.zip压缩包里面有word源文件16.doc,image1.pdf是通过aspose.word通过16.doc转出来的。
我使用IWarningCallback 测试,没有发现任何字体被替换的日志。我看16.doc的字体都是宋体加粗的,我查看该服务器上有宋体的字体文件,还有什么原因会导致该服务器上的文字显示不出来呢
public static void main(String[] args) throws Exception {
final String arg1 = args[0];
final String arg2 = args[1];
final String arg3 = args[2];
final String arg4 = args[3];
System.out.println(arg1);
System.out.println(arg2);
System.out.println(arg3);
System.out.println(arg4);
Document doc = new Document(arg1);
QysWarnings warnings = new QysWarnings();
doc.setWarningCallback(warnings);
FontSettings fontSettings = FontSettings.getDefaultInstance();
FolderFontSource folderFontSource = new FolderFontSource(arg3, false, 1);
SystemFontSource systemFontSource = new SystemFontSource(2);
fontSettings.setFontsSources(new FontSourceBase[] {systemFontSource, folderFontSource });
doc.setFontSettings(fontSettings);
// doc.getLayoutOptions().setCommentDisplayMode(CommentDisplayMode.HIDE);
doc.acceptAllRevisions();
System.out.println("开始查看字体名1");
FontInfoCollection fonts = doc.getFontInfos();
for (FontInfo font : fonts)
System.out.println(font.getName());
System.out.println("查看字体名结束2");
PdfSaveOptions opts = new PdfSaveOptions();
opts.setUpdateFields(false);
opts.setSaveFormat(SaveFormat.PDF);
doc.save(arg2, opts);
}
public static class QysWarnings implements IWarningCallback {
public void warning(WarningInfo info) {
if (info != null) {
if (info.getWarningType() == WarningType.FONT_SUBSTITUTION) {
String warningTypeStr = WarningType.toString(info.getWarningType());
String description = "转换警告类型【" + warningTypeStr + "】, 警告详情信息:" + info.getDescription();
System.out.println(description);
}
}
}
}