Converting a DOCX to HTML and convert it back to DOCX changed table margin value

Hi,

When I converted a DOCX (not in compatibility mode) to an HTM file using Aspose.Words, then converted it back to DOCX. I noticed the DOCX became in compatibility mode and margin value was changed unexpectedly.

Code:
var doc = new Document(@".\test.docx");
var htmlSaveOption = new HtmlSaveOptions();
htmlSaveOption.AllowNegativeIndent = true;
doc.Save(@".\out.htm", htmlSaveOption);
var htmlDoc = new Document(@".\out.htm");
htmlDoc.Save(@".\convertedBack.docx");

The negative margin value was -0.5cm in the original document, but it became -0.3cm in the final document.

I’ve attached the test files and a screenshot for your reference. Could you please help me check?

test.zip (15.9 KB)
image.png (75.4 KB)

Thanks,

@ServerSide527,

Please use the following code to fix this issue:

Document doc = new Document("E:\\test\\test.docx");
var htmlSaveOption = new HtmlSaveOptions();
htmlSaveOption.AllowNegativeIndent = true;
doc.Save("E:\\test\\19.2.htm", htmlSaveOption);

var htmlDoc = new Document("E:\\test\\19.2.htm");
htmlDoc.CompatibilityOptions.OptimizeFor(MsWordVersion.Word2016);
OoxmlSaveOptions opts = new OoxmlSaveOptions(SaveFormat.Docx);
opts.Compliance = OoxmlCompliance.Iso29500_2008_Transitional;
htmlDoc.Save("E:\\test\\19.2.docx", opts); 

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-18144. 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.