1. 程式人生 > 其它 >aspose word轉pdf,linux預覽亂碼問題

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.重啟服務