aspose word转pdf,linux预览乱码问题

解决方法

1.将window中字体放到linux中,上传至/usr/shared/fonts/chinese目录下,接下里用

https://blog.csdn.net/GZSGZSgg/article/details/95641217?utm_medium=distribute.pc_aggpage_search_result.none-task-blog-2~aggregatepage~first_rank_ecpm_v1~rank_v31_ecpm-1-95641217.pc_agg_new_rank&utm_term=aspose%E4%B9%B1%E7%A0%81+linux&spm=1000.2123.3001.4430

https://blog.csdn.net/chi_666/article/details/114606893?utm_medium=distribute.pc_aggpage_search_result.none-task-blog-2~aggregatepage~first_rank_ecpm_v1~rank_v31_ecpm-3-114606893.pc_agg_new_rank&utm_term=aspose%E4%B9%B1%E7%A0%81&spm=1000.2123.3001.4430

2.在aspose代码中添加

@SneakyThrows
public static void wordToPdf(String wordPath, String pdfPath) {
getLicense();
File file = new File(pdfPath);
try (FileOutputStream os = new FileOutputStream(file)) {
OsInfo osInfo = SystemUtil.getOsInfo();
if(osInfo.isLinux()){
FontSettings.setFontsFolder("/usr/share/fonts/chinese", true);
}
Document doc = new Document(wordPath);
doc.save(os, SaveFormat.PDF);
}
}
3.重启服务
posted @ 2021-12-24 13:56  水墨年华  阅读(601)  评论(0)    收藏  举报