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

Free Support Forum - aspose.com

H3 doesn't support CSS classes when converted from HTML to Word or HTML to PDF

We have Aspose.Total license and we are using Aspose v21.7.0 for converting HTML to Word and PDF document.

In the Html we have H3 tags for which we add class=“some-class-name” property in html. If their is no such class defined in CSS, then the default style is applied to H3 tag which is fine.

But if CSS class is defined in the styles section and that class is applied to H3 element, then, in the generated word document, that element is not rendered as an header tag. Instead it is rendered as a normal text with the styles applied.

But when the html contains style=“some styles here” it is working as expected.

In short, when css class is applied to H3 element, it looks fine as expected, but it is no more rendered as a header.

Please find the sample HTML which can be used to reproduce the issue: H3 Header Issue.zip (1.3 KB)


Could you please specify which Aspose API are you using from the Aspose.Total package to create Word and PDF files through HTML? Please also share the sample code snippet so that we can test the scenario in our environment and address it accordingly.

Thank you for your prompt reply. I will provide you the details about API and code sample ASAP. But for now just to let you know, this is reproducable in web version of converter as well which is quick to test (if that helps): https://products.aspose.app/words/conversion/html-to-word

Here is the sample code requested by you @asad.ali

// This is an abstract of what we have in code

var inputStream = /* Stream of the html */
var doc = new Aspose.Words.Document(inputStream, new LoadOptions { Encoding = Encoding.UTF8 });

var filename = /* some docx file name */
var stream = new MemoryStream();
var saveOptions = SaveOptions.CreateSaveOptions(filename);

doc.Save(stream, saveOptions);

// Now stream contains the document

We have tested the scenario and managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET - 23183. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

Thank you @sergey.lobanov for the updates. I will keep monitoring this forum for any future updates.

Just in case if you missed it, letting you know. This issue is not just with HTML to WORD. This happens with HTML to PDF as well. Just trying to highlight so that it is not missed. Thank you.

@shridhartl Thank you for additional information. Yes it is noticed.

The issues you have found earlier (filed as WORDSNET-23183) have been fixed in this Aspose.Words for .NET 22.8 update also available on NuGet.