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

Free Support Forum - aspose.com

Css child class


I started use aspose pdf with html rendering.
I get some issue to customise my html with some css.
It looks like the child css classes not working.


Hello World!

CSS 1: ok!
.section {
color: red;
CSS 2: ko!
.section > h3 {
color: red;
CSS 3: ko!
.section h3 {
color: red;
CSS 4: ko!
.section .test {
color: red;

HI Julien,

Thanks for your inquiry. Recently, we’ve introduced HTML to PDF DOM approach in Aspose.Pdf for .NET 8.5.0. Please download and try latest API with following sample code snippet, child css classes are working with new approach. Hopefully your issue will be resolved.

HtmlLoadOptions options = new HtmlLoadOptions();<o:p></o:p>

// use the new conversion engine<o:p></o:p>

options.UseNewConversionEngine = true;<o:p></o:p>

// load HTML file<o:p></o:p>

Document pdfDocument = new Document(myDir + “Test.html”, options);<o:p></o:p>

// save output as PDF format<o:p></o:p>

pdfDocument.Save(myDir + “HTMLtoPDF_DOM.pdf”);<o:p></o:p>


<o:p>Please feel free to contact us for any further assistance.</o:p>

Best Regards,

Thanks for your answer!
But we currently use Aspose pdf 6.8.0.
We don’t use the object Document but directly the Pdf object and customise it

The code look like this:
Pdf pdf = new Pdf();
pdf.HtmlInfo.ExternalResourcesBasePath = pageContent.CssFilePath;
Section section = pdf.Sections.Add();
section.PageInfo.Margin = GetMargin(90,50, 40, 40);
HeaderFooter header = new HeaderFooter(section);
header.Margin = GetMargin(20, 20, 0, 0);
HeaderFooter footer = new HeaderFooter(section);
footer.Margin = GetMargin(20, 20, 0, 0);

Text footerText = new Text(“Some text”) { IsHtmlTagSupported = false };
Text bodyText = new Text(“BodyHTMLContent”) { IsHtmlTagSupported = true };
Text headerText = new Text(“HeaderHltmContent”) { IsHtmlTagSupported = true };


section.IsLandscape = pageContent.IsLandscape;
section.OddFooter = footer;
section.EvenFooter = footer;
section.OddHeader = header;
section.EvenHeader = header;

using (FileStream st = File.Open(fullPathName, FileMode.Create, FileAccess.Write))

So, does this version support the child css?
Does your solution still work if we use that way to generate the pdf file?

thanks by advance!

Hi Julien,

Thanks for your feedback. I’m afraid the requested functionality is not supported in Aspose.Pdf.Generator. I’ve logged an investigation ticket as PDFNEWNET-35891 in our issue tracking system for further investigation and resolution.

Moreover, Aspose.Pdf.Document(DOM approach) renders HTML to PDF document but currently, it doesn’t support to include HTML contents in PDF document, as you are including HTML using IsHtmlTagSupported property. We’ve already logged this feature request as PDFNEWNET-35804 in our issue tracking system. We will update you via this forum thread as soon as its resolved.

We are sorry for the inconvenience caused.

Best Regards,

The issues you have found earlier (filed as PDFNEWNET-35804) have been fixed in Aspose.Pdf for .NET 9.5.0.

This message was posted using Notification2Forum from Downloads module by Aspose Notifier.

Hi Julien,

Thanks for your patience. As stated above PDFNEWNET-35804 is also resolved and now you can add HTML string in new/existing document using new DOM approach. Please check following documentation link for the purpose. It will help you to accomplish your requirements.

Please feel free to contact us for any further assistance.

Best Regards,

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