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

Free Support Forum - aspose.com

How to add css styles export HTML to word

How to add css styles , which is written in as classes .

these classes should get applied to HTML tags.

how to apply these css classes to HTML tags using Aspose.Word when exporting HTML to Word.

Hi Jeevan,


Thanks for your inquiry.

Aspose.Words supports most CSS properties that have an equivalent use in Microsoft Word documents. You can set the LoadOptions.BaseUri path of the document being loaded so relative resources can be correctly imported. This property is used to resolve relative URIs into absolute when loading an HTML document from a stream. So, Aspose.Words automatically downloads an external or linked CSS sheet from an external address on the internet.

Moreover, please note that during loading Html document into Aspose.Words’ DOM, it automatically applies the CSS to the content in the following ways:

  1. If styles are written inline (as a value of the style attribute on every element) in HTML.
  2. If styles are written separately from the content in a style sheet embedded in the HTMLL file.
  3. If styles are written separately from the content in a style sheet in an external file (The HTML file should specify a link to the style sheet.)

Please let me know if I can be of any further assistance.

Best regards,

Hi Awais ,

I tried to export HTML to Word using Aspose , In .net windows (EXE) application

I used doc.InsertHtml() to this HTML stream is passed which contains tag and HTML elements.

In style css classes specified .

but in output Word document none of CSS applied…


Regards ,
Jeevan Joshi.

Hi Jeevan,

Thanks for your inquiry. Could you please attach your input HTML document here for testing? I will investigate the issue on my side and provide you more information.

Best regards,

Hi Awais

Thanks for your reply…

below is HTML stream with CSS…




table.c1, table.AshGrid td.c1, div.c1{background-color: #ff825e;}


.bg-green {background-color: #CCCC99;}
style>








ABC


Hi Jeevan,


Thanks for your inquiry.

While using the latest version of Aspose.Words i.e. 11.11.0, I managed to reproduce this issue on my side. The background-color of Cell is not coming out correctly in output Word documents. I have logged this issue in our bug tracking system. The issue ID is WORDSNET-7695. Your request has been linked to this issue and you will be notified as soon as it is resolved.

Sorry for the inconvenience.

Best regards,

Hi Awais ,

I am waiting for your reply (about bug) …

and can you give me example with code how to create MsWord document for HTML stream where
css is in tag and content in


Regards ,

Jeevan Joshi.

Hi Jeevan,


Thanks for your inquiry.

Unfortunately, your issue is not resolved yet. The responsible developer has completed the analysis of this issue and the root cause has been determined. I regret to share with you that this problem has now been postponed till a later date. We will inform you as soon as this issue is resolved. We apologize for your inconvenience.

As described here, by default when Aspose.Words laods a HTML based document, it automatically loads the CSS that is embedded in the HTML file. But, it is not guaranteed that the output Word document will look exactly the same as the input HTML. This is because Aspose.Words was originally designed to work with Microsoft Word documents and HTML documents are quite different. However, Aspose.Words’ HTML engine tries to mimic the way the Microsoft Word works.

Best regards,

The issues you have found earlier (filed as WORDSNET-7695) have been fixed in this .NET update and this Java update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.