TOC font style

hi
i am trying to edit toc font to be “Arial” with size 8 but the result is a toc with multiple font: Times new roman and Calibri size 10.
how can i set it?

this is my code

_docBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Justify;
_docBuilder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Normal;
_docBuilder.Font.Bold = false;
_docBuilder.Font.Italic = false;
_docBuilder.Font.Name = "Arial";
_docBuilder.Font.Size = 10;
_docBuilder.Font.Color = Color.Black;
Field tableOfContent = _docBuilder.InsertTableOfContents("\o "
    1 - 5 " \h \z ");
_docBuilder.InsertBreak(BreakType.PageBreak);

…chapters…

tableOfContent.Update();
_document.UpdateFields();
_document.UpdatePageLayout();

the version of Aspose.Words.dll is 11.11 .0 .0

Hi there,

Thanks for your inquiry. You can change formatting of TOC items by changing Toc1, Toc2…Toc9 styles. You need to change the style for each level in the table of contents. Please see the following code example for your kind reference.

// Use a blank document
Document doc = new Document();
// Create a document builder to insert content with into document.
DocumentBuilder builder = new DocumentBuilder(doc);
Style toc1 = doc.Styles[StyleIdentifier.Toc1];
toc1.Font.Bold = false;
toc1.Font.Bold = false;
toc1.Font.Size = 10;
toc1.Font.Name = "Arial";
// 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.
builder.InsertBreak(BreakType.PageBreak);
// 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.UpdateFields();
doc.Save(MyDir + "out.docx");