Free Support Forum -

Wrong SpaceAfter while Reading and Saving

Hi, there are two problems using the Aspose.Words.
First, each line in the original file “SpaceAfter” is 0. But according to Aspose.Words, SpaceAfter of each line is 10. The new file saved using Aspose.Words will be an empty line between two lines.

Second, fail to use Aspose.Words loading the document org2.docx.
Here are the files for both ploblems. (6.0 MB)

Hope to get some help.,

Regarding the ‘Wrong SpaceAfter’ problem you are observing with org.docx, 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-19503. 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.

Regarding the FileCorruptedException you are getting with org2.docx, after an initial test with the licensed latest version of Aspose.Words for .NET i.e. 19.10, we were unable to reproduce this issue on our end.

So, please upgrade to the latest version i.e. 19.10. Hope, this helps.,

Regarding WORDSNET-19503, we have completed the work on your issue and concluded to close this issue as ‘Not a Bug’. Please see below the analysis details.

The issue occurs because the default paragraph properties of the document are missing. MS Word adds values depending on version. The following code fixes the issue:

LoadOptions lo = new LoadOptions();
lo.MswVersion = MsWordVersion.Word2013;

Document doc = new Document("E:\\Temp\\Ploblem\\org.docx", lo);
foreach (Section srcSection in doc.Sections)
    foreach (Object srcNode in srcSection.Body)
        if (((Node)srcNode).NodeType == NodeType.Paragraph)
            Paragraph para = (Paragraph)srcNode;
            ParagraphFormat parFormat = para.ParagraphFormat;
            Console.WriteLine("SpaceAfter:" + parFormat.SpaceAfter);

How I can ensure the default paragraph properties of the document missing?
Can you offer the code for us?

Unfortunately, Aspose.Words currently does not offer any API for it. You can see it in XML file ~/word/styles.xml inside DOCX document. Please see attached screenshot, w:pPrDefault element is missing.

Screenshot 2019-11-06 21.12.47.png (40.1 KB)

I tested your code.
Below is debug information.
1.png (14.6 KB)

You can see that the value of SpaceAfter is still 8.The expected value is 0.It is disappointing that it don’t works.

My Aspose.Words Version is 19.9。
2.png (12.8 KB)

Tips: My org.doc is created by wps office(Kingsoft Corporation Limited) which is very popular software in China.So this question is very importtant because I can’t ignore this large percent files.

I am looking forward to your another solution. Thanks!,

But, as shown in following screenshot, MS Word 2019 reveals on our end that the SpaceAfter values for both paragraphs are 8.

If you do not specify LoadOptions, then Aspose.Words will return 10, otherwise 8 as SpaceAfter value.

A post was split to a new topic: LineSpacing changes during saving WPS document,

Regarding WORDSNET-19503, it is to update you that starting from the 20.2 release, Aspose.Words follows MS Word 2013’s behavior and setting MswVersion2013 explicitly is not required anymore.

Also, what we understand is you are expecting value 0. We have found that if any CJK (Chinese, Japanese, and Korean) language is set in Office Language Preference dialog then MS Word does not update missing defaults and leaves spacing equal to 0. This behavior has been implemented, so you should now set CJK language as default using LoadOptions.LanguagePreferences.

Hope, this helps.