We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Creating Word doc from HTMl

I’m using the aspose.words to take a word doc and convert it to html and placing the html into a HTML Editior, giving the user the ability to edit a document outside of word. Then i convert the html back into a word document using the document builder inserthtml, but it seems to create a mixed formatted word document. It has mixed html and normal formatted data in the new document. is there a simple way of creating a new word doc from html and have it formatted the same as the html?

I’ve attached the original document and the final created document, not modifying anything from the original and pushing the html back into and blank word document and you can see the document is not correctly formatted like the html.

Hi Mike,

Thanks for your inquiry. First off, I would suggest you please use the latest version of Aspose.Words (14.4.0). You can download it from the following link:

Secondly, you can use the following code to achieve this requirement:

Document doc = new
Document(MyDir + @“Original.doc”);

doc.Save(MyDir + @"intermediate.html");

Document docHtml = new Document(MyDir + @"intermediate.html");

docHtml.Save(MyDir + @“Final.doc”);

Also, please note that it is not guaranteed that the final DOC output will look exactly the same as the input DOC during the DOC to HTML to DOC round-trip. This is because Word and HTML formats are quite different. I would suggest you please visit the following links to learn about the features supported during importing/exporting from/to HTML format.


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

Best regards,

Actually i need to edit it first in the htmleditor control then save that html back to a word document. i was able to get the content into the document now by doing Server.HtmlDecode(textbox.text) when using the db inserthtml method. the only thing is i seem to loose some of the styles in the orignal document like margins and what not. is there a way with aspose to take style from a template document and apply it to this newly created document from my html?

Hi Mike,

Thanks for your inquiry. Sure, the following code demonstrates how to copy style from one document into a different document.

// This is the style in the source
document to copy to the destination document.

Style srcStyle = srcDoc.Styles[StyleIdentifier.Heading1];

// Change the font of the heading style to red.

srcStyle.Font.Color = Color.Red;

// The AddCopy method can be used to copy a style from a different document.

Style newStyle =

Please let us know if we can be of any further assistance.

Best regards,

Is there a way to just copy all styles at one time from the original document?

Hi Mike,

Thanks for your inquiry. Please use the following code to copy all styles from one document to another document:

Document docA = new Document(MyDir + @“in.docx”);

Document docB = new Document();

foreach (Style styleA in docA.Styles)


docB.Save(MyDir + @“out.docx”);

I hope, this helps.

Best regards,