Custom Styles Not Associated on Doc Converted to HTML


After converting the attached word document to html, the custom styles are not retained (associated) when copy pasting from the html back to a word document. The formatting that the custom style had is however translated to the document.

There are different custom styles in a single paragraph.
We are using the CssStyleSheetType = CssStyleSheetType.Embedded when doing the conversion from word to html.


Hi Mia,

Thanks for your inquiry. It is expected behavior. Please note Aspose.Words mimics same behavior as MS Word does. If you convert attached document to HTML using MS Word and then copy paste the HTML into Word document. It does not import the Styles but retain the formatting.

Document doc = new Document("customStyles.docx");
Aspose.Words.Saving.HtmlSaveOptions options = new Aspose.Words.Saving.HtmlSaveOptions(SaveFormat.Html);
options.ExportRoundtripInformation = true;
doc.Save("Out.html", options);
doc = new Document("Out.html");

Please feel free to contact us for any further assistance.

Best Regards,

Thank you for responding so soon.

I have done a test with Word 2016 whereby I save the document as html or mht. When I then open that html or mht in the browser (IE11 & Edge) and then copy from the browser to a new Word 2016 document, all the formatting and custom styles are coming across. You are welcome to verify this yourself.

If as you say Aspose.Words mimics MS Words save as HTML or MHT, then I feel that Aspose.Words should do the same and bring across the formatting and styles and associate the styles to the text that was copied. Then this should be logged as a bug.

We are using Aspose.Words 17.5.0.

Hi Mia,

Thanks for sharing your feedback. I have tested the scenario with Chrome web browser, it is not importing the styles when we copy MS Word generated HTML to Word document. However, as you stated as well, I have noticed that IE is importing styles. So, we have logged a ticket WORDSNET-15440 in our issue tracking system for further investigation and rectification. We will notify you as soon as it is resolved.

Best Regards,


Thanks for your patience. Our product team has investigated the issue and found it is not a bug in Aspose.Words but expected behavior. We see the following two issues here:

  • Styles from ‘class’ attributes are not assigned to corresponding paragraphs. It is a strange behavior of MS Word. It refuses to assign styles to paragraphs in case the HTML fragment being inserted contains HTML lists (“ul”,“o” and “li”). If you select only the first two paragraphs in Chrome (everything but the list) and paste them into an MS Word document, styles will be assigned correctly. Note that HTML documents produced by MS Word don’t contain HTML lists, because MS Word always exports list items as normal paragraphs. As a workaround, you can set HtmlSaveOptions.ExportListLabels=ExportListLabels.AsInlineText in order to disable export of HTML lists in Aspose.Words and mimic MS Word’s behavior.
  • Formatting from custom styles is converted to direct formatting. Custom styles pasted from HTML are empty. This conversion is performed by Chrome at the moment a HTML fragment is copied to Clipboard. Chrome doesn’t preserve the original stylesheet and resolves all CSS into inline styles.

Best Regards,

Hi, sorry for the late response. Thanx, This has helped us out.

The issues you have found earlier (filed as ) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by MuzammilKhan