Preserve Effect of Office Language Preferences on CJK Language Paragraph Spacing during DOCX Processing in Java

Hi
I just open a document, and save it, but the style has modified. All the paragraph line span the become 1.15 linewidth,and there are 10 pounds after the paragraph.
The source code is as following. And my version is 16.8.0.
Document d = new Document(“E:\source.docx”);
d.save(“E:\dest.docx”,SaveFormat.DOCX);

And the attachment is as follows.
source.png (7.2 KB)
dest.png (7.6 KB)

@skyzhang,

Thanks for your inquiry. Please try the latest version of Aspose.Words for Java i.e. 19.11 and see how it goes on your end? In case the problem still remains, please ZIP and upload your input Word document and Aspose.Words 19.11 generated DOCX file showing the undesired behavior here for testing. We will then investigate the issue on our end and provide you more information.

Thank u for your reply so quickly. I have test using 19.11 . But the style is still wrong.

source-2.zip (9.9 KB)
dest-2.zip (9.4 KB)

@skyzhang,

We tested the scenario and have managed to reproduce the same problem on our end. For the sake of correction, we have logged this problem in our issue tracking system. The ID of this issue is WORDSNET-19603. We will further look into the details of this problem and will keep you updated on the status of correction. We apologize for your inconvenience.

@skyzhang,

Regarding WORDSNET-19603, the issue occurs because the default properties of the document are missing. MS Word adds values depending on version. In this case, you need to specify MS Word version explicitly by using LoadOptions. The following code fixes the issue:

LoadOptions opts = new LoadOptions();
opts.setMswVersion(MsWordVersion.WORD_2013);
Document doc = new Document("E:\\source.docx", opts);
doc.save("E:\\dest.docx", SaveFormat.DOCX);

Please let us know how it goes on your end?

I have tested using the code as your suggestion, but it doesn’t effect. And I test MsWordVersion.WORD_2013, MsWordVersion.WORD_2016, MsWordVersion.WORD_2010, MsWordVersion.WORD_2007, all of those have no effection

@skyzhang,

Thanks for the additional information. We have logged your concerns in our issue tracking system and will keep you posted on any further updates.

I have checked styles.xml. And I found that aspose.word will add the following default paragraph style if the original document no this style.
<w:pPrDefault>
<w:pPr>
<w:spacing w:after=“200”; w:line=“276”; w:lineRule=“auto”;/>
<w:pPr>
<w:pPrDefault>

This is the reason that the bug occurred. Can you fixed this bug?

@skyzhang,

Thanks for sharing your further input on this topic. We will inform you via this thread as soon as this issue will be resolved or any further updates may be available. We apologize for any inconvenience.

@skyzhang,

Please also share a screenshot of “Office Language Preferences” dialog. We found recently that behavior could differ for CJK languages. Thanks for your cooperation.

The issues you have found earlier (filed as WORDSNET-19603) have been fixed in this Aspose.Words for .NET 20.5 update and this Aspose.Words for Java 20.5 update.