Avoid Unexpected margin-left of Paragraph of Image after DOCX to HTML Conversion using C# .NET Code

This docx file is rendered into html through .NET. Two identical pictures in the file render different styles. The first picture has an style marginLeft

Why is there such a situation and how can I avoid it。


We have logged the following issue in our bug tracking system.

  • WORDSNET-21067: Unexpected margin-left added to the parent Paragraph of Image after DOCX to HTML conversion

We will further look into the details of this problem and will keep you updated on the status of the linked issue.

Is there any progress on this issue now


Unfortunately, WORDSNET-21067 is not resolved yet. This issue is currently pending for analysis and is in the queue. We will inform you via this forum thread as soon as this issue will get resolved in future. We apologize for any inconvenience.


The problem (WORDSNET-21067) occurs because the source document contains a Shape with negative indent; so to fix this problem, you should use HtmlSaveOptions.AllowNegativeIndent option.

Document doc = new Document("C:\\temp\\test.docx");
HtmlSaveOptions so = new HtmlSaveOptions();
so.AllowNegativeIndent = true;
doc.Save("C:\\temp\\20.9.html", so);

So, it is expected behavior when saving with HtmlSaveOptions.AllowNegativeIndent=false. Both images have negative left indent (parts of them are located on page margins) and are subject to left margin adjustments according to the HtmlSaveOptions.AllowNegativeIndent=false setting. In order to disable ‘left-margin’ adjustments, please save the document with HtmlSaveOptions.AllowNegativeIndent=true. You might also find the HtmlSaveOptions.ExportPageMargins=true setting useful.

Also, please note that we have now completed the work on this issue and concluded to close this issue with “Not a Bug” status.