How to solve the line breaking problem of "-" characters in Word to pdf

Hyphenation.registerDictionary("en-US", "D:\\java\\work\\chinairi\\asposedic\\dictionaries-master\\en\\hyph_en_US.dic");
Document document = new Document("D:/sl2.docx");
document.save("D:/LoadHyphenationDictionaryFromFile_Out.pdf");

问题.zip (132.0 KB)

@Mikeykiss Aspose.Words and MS Word use different rules of document layout depending of the proffered language used. In you case you can solve the issue by setting the following options while document conversion:

Document doc = new Document("C:\\Temp\\sl2.doc");

doc.getCompatibilityOptions().setUseFELayout(true);
doc.getStyles().getDefaultFont().setLocaleIdFarEast(2052);

doc.save("C:\\Temp\\out.pdf");

Here is output document produced on my side using the latest 22.9 version of Aspose.Words: out.pdf (88.9 KB)

Thanks very much. It worked. This problem was solved

1 Like