Heading Styles Are Lost When Font Style Settings Are Used

I created a Table Of Contents method based on the example in your API and combined it with a styled sentence (i.e., with font style changes), also based on the example in your API. However, the styled sentence negated all of the Heading style fonts. The method is included in this message. How can you keep the Heading styles? In the attached code, I tried reverting back to the original font settings, but that did not work either.

The code file is attached as a text document.

Thank you.

I found the solution in reference 186700 in reply to 186664, a NET solution. The solution was to add "clearFormatting" after the specialized format section:

builder.getFont().clearFormatting();

The "clearFormatting()" command returned to the original paragraph formatting and the original Heading style formatting.

The original solution was provided by:

Alexey Noskov
Developer/Technical Support
Aspose Auckland Team

.getFont().clearFormatting();

Hi Martin,

Thanks for your inquiry. It is nice to hear from you that you have found the solution of your issue. Yes, DocumentBuilder.Font.ClearFormatting resets to default font formatting. Please also use ParagraphFormat.ClearFormatting to reset to default paragraph formatting.

Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.