H2 / h3 tags not working? But they are supported

I have a very simple test html that i want to convert to pdf. I made a small test program to test this but i ran into a problem. Code:


var content = @"
Test

Title here 1

Some content here…

Title here 2

Some content here…

Title here 3

Some content here…
";

var pdf = new Pdf();
pdf.HtmlInfo.BadHtmlHandlingStrategy = BadHtmlHandlingStrategy.ThrowException;
pdf.HtmlInfo.ShowUnknownHtmlTagsAsText = true;

var section = pdf.Sections.Add();

var html = new Text(content);
html.IsHtmlTagSupported = true;
section.Paragraphs.Add(html);

pdf.Save(“D:\temp\tmp.pdf”);
System.Diagnostics.Process.Start(“D:\temp\tmp.pdf”);

The rendered output shows the h2 and h3 tags as text. They are on the supported list (and should be :)) but they are not recognized. Am i doing something wrong? I am using 9.1.0 trial version.

HI Herman,

Thanks for your patience. We have introduced HTML to PDF DOM approach since Aspose.Pdf for .NET 8.5.0. Please try following code snippet, it will fix the issue.

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 + htmlheadings.html”, options);

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

pdfDocument.Save(myDir + testhtmlHeadings.pdf”);

<o:p>
</o:p>

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


Best Regards,