When you convert a word file to PDF, the Chinese characters in the word file will be broken and converted. I need help.
test.docx (5.8 MB)
java code
String wordFilePath = "D:" + File.separator + "test.docx";
String pdfFilePath = "D:" + File.separator + "test.pdf";
Document pdf = new Document(wordFilePath);
FontSettings fontSettings = new FontSettings();
String fontsDir = "C:\\Windows\\Fonts";
fontSettings.setFontsFolder(fontsDir, true);
pdf.setFontSettings(fontSettings);
PdfSaveOptions saveOptions = new PdfSaveOptions();
saveOptions.setEmbedFullFonts(true);
saveOptions.setUseCoreFonts(true);
saveOptions.setSaveFormat(SaveFormat.PDF);
pdf.save(pdfFilePath, saveOptions);