Different Color of TOC

Hi. May I create TOC using different color?
For example:
Start TOC
Red String
Blue String
Gree String
End TOC


Thanks

Hi,

Perhaps the easiest way would be to insert a TOC, update it, and then change the “TOC 1” and “TOC 2” styles per your requirement.

So, something like this:

var toc = new TableOfEntries(document, FieldType.TOC, @" \o ""1-3"" \h \u ");
document.Sections[0].Blocks.Insert(0, toc);

toc.Update();

var toc1Style = document.Styles["toc 1"] as ParagraphStyle;
toc1Style.CharacterFormat.FontColor = Color.Red;

var toc2Style = document.Styles["toc 2"] as ParagraphStyle;
toc2Style.CharacterFormat.FontColor = Color.Blue;

Does this solve your issue?

Regards,
Mario

It’s amazing. Thanks!