Hi Charan,
Thanks for your inquiry. Well, in your case, every node of TOC field is represented by a HYPERLINK field. When you click on a TOC item, the control jumps to a particular location in your document pointed by a hidden Bookmark. I think, you can implement the following workflow to achieve what you’re looking for:
Document doc = new Document(MyDir + @“TOC_Document.docx”);
foreach (Field field in doc.Range.Fields)
{
if (field.Type.Equals(FieldType.FieldHyperlink))
{
FieldHyperlink hyperlink = (FieldHyperlink)field;
if (hyperlink.SubAddress.StartsWith("_Toc"))
{
Paragraph tocItem = (Paragraph)field.Start.GetAncestor(NodeType.Paragraph);
if (tocItem != null)
{
//
do something
if (tocItem.ParagraphFormat.LeftIndent == 12)
Console.Write("\t");
Console.WriteLine(tocItem.ToString(SaveFormat.Text));
}
}
}
}
I hope, this helps.
Best regards,