Document mainDoc = new Document(wordPathUrl);
//设置字体
FontSourceBase[] originalFontSources = FontSettings.getDefaultInstance().getFontsSources();//默认字体源
// 从包含字体的文件夹创建字体源。
FolderFontSource folderFontSource = new FolderFontSource(FontsDir, true);
// 应用一个新的字体源数组,其中包含原始字体源以及我们的自定义字体。
FontSourceBase[] updatedFontSources = {originalFontSources[0], folderFontSource};
FontSettings.getDefaultInstance().setFontsSources(updatedFontSources);
mainDoc.save("test.docx", SaveFormat.DOCX);
aspose为文档设置字体
最新推荐文章于 2024-08-01 15:05:06 发布