I have a docx file that created by WPS,When i replace something using Aspose.Words,the line spacing has been change.
the version is Aspose.Words for .Net 20.12.0.0. 20211216215514.png (4.3 KB)
@sullivan,
Unfortunately, we were unable to reproduce the same issue on our side. On my side, the line spacing in your input and output documents are the same, when opened using MS Word.
Please note that Aspose.Words mimics the behavior of MS Word. The text formatting may look different in other applications.
@sullivan The problem occur because WPS Office does not write paragraph spacing defaults into the document. You can unzip input and output document, open styles.xml and you will see the following: source
As you can see in the source document there is no pPrDefault element. It seems WPS Office has these defaults hardcoded or defined in it’s templates.
Aspose.Words in this case mimics MS Word behavior and writes the missed defaults into the output document. You can change the defaults programmatically to make the document look the same as in WPS Office. For example see the following code:
Document doc = new Document(@"C:\Temp\demo.docx");
doc.Styles.DefaultParagraphFormat.SpaceAfter = 0;
doc.Save(@"C:\Temp\out.docx");
I am not sure zero is correct value, but it seems it is what you see in WPS Office.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
Enables storage, such as cookies, related to analytics.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.