Alignment issues while Converting Html to DocX using Aspose

hi

While converting html to Docx using Aspose I found some table alignment, margin alignment, Image resizing probles and in some html input style tags not converting properly. Please refer the code i have used and screen shots as attached.

private void Html2AsposeDocx()
{
byte[] docBytes;
Document doc = new Document();

using (MemoryStream finaloutstream = new MemoryStream())
{
DocumentBuilder builder = new DocumentBuilder(doc);
//Insert HTML
builder.InsertHtml(File.ReadAllText(@"d:\TestHtmls\test.html", Encoding.UTF8));
doc.Save(finaloutstream, SaveFormat.Docx);
docBytes = finaloutstream.ToArray();
System.IO.File.WriteAllBytes(@"D:\s.docx", docBytes);
}
}

Hi Rathinam,


Thanks for your inquiry. The latest version of Aspose.Words 14.4.0 mimics the way the Microsoft Word imports your HTM files to Word format. I have attached coresponding three Word documents i.e. produced by using Microsoft Word 2013 application here for your reference (see msw-Caesarean Section - Blank view.docx, msw-Caesarean Section - Details View.docx and msw-Clinical Observation - Blank Form View.docx).

So, it is not guaranteed that when you convert a HTML file using Aspose.Words, the output Word document will look exactly the same as the HTML file rendered in web browser. This is because Aspose.Words was originally designed to work with Microsoft Word documents and HTML documents are quite different. For details, please refer to the articles mentioned in the following page:

If we can help you with anything else, please feel free to ask.

Best regards,