Word TOC does not show Heading1 any more

I am using word.dll v14.3.0.0

All of a sudden my code that creates the TOC
no longer shows any headings with style of Heading1

This used to work just fine in word.dll v13.4.0.0


here is some of the code I have

builder.InsertTableOfContents("\\o \"1-3\" \\h \\z \\u");

Document docChapter = AsposeHelperManager.RtfStringToDocument(Rtf);
// Make sure Title of document is of style Heading1
docChapter.FirstSection.Body.FirstParagraph.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading1;

By the way Heading2 and Heading3 work just fine.

Can you please help me.
I just released a new version of my tool and now my customers
are complaining that the TOC no longer shows the heading1

Hi Nitin,

Thanks for your inquiry. After an initial test with Aspose.Words 14.3.0, I was unable to reproduce this issue on my side. Please see the attached out.docx i.e. generated on my side using the following code:

// Use a blank document
Document doc = new Document();
// Create a document builder to insert content with into document.
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert a table of contents at the beginning of the document.
builder.InsertTableOfContents("\\o \"1-3\" \\h \\z \\u");
// Start the actual document content on the second page.
// Build a document with complex structure by applying different heading styles thus creating TOC entries.
builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading1;
builder.Writeln("Heading 1");
builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading2;
builder.Writeln("Heading 1.1");
builder.Writeln("Heading 1.2");
builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading1;
builder.Writeln("Heading 2");
builder.Writeln("Heading 3");
builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading2;
builder.Writeln("Heading 3.1");
builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading3;
builder.Writeln("Heading 3.1.1");
builder.Writeln("Heading 3.1.2");
builder.Writeln("Heading 3.1.3");
builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading2;
builder.Writeln("Heading 3.2");
builder.Writeln("Heading 3.3");
// Call the method below to update the TOC.
doc.Save(MyDir + @"out.docx");

To ensure a timely and accurate response, please attach the following resources here for testing:

  • Your input Word document.
  • Your output Word document showing the undesired behavior.
  • Please create a standalone runnable simple console application that helps us reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we’ll start investigation into your issue and provide you more information.

Best regards,