Retrieve Table of Contents
Contents
[
Hide
]
Retrieve Table of Contents in C#
GroupDocs.Parser (which is a part of Conholdate.Total for .NET) allows you to extract table of contents from PDF documents, Ebooks and Microsoft Word (DOC, DOCX etc).
To extract TOC you need to use GetToc method.
IEnumerable<TocItem> GetToc()
TocItem class has the following members.
Member | Description |
---|---|
Depth | The depth level. |
PageIndex | The page index. |
Text | The text. |
TextReader ExtractText() | Extract a text from the document to which TocItem object refers. For detail |
Follow the steps below to retrieve table of contents from the document.
- Instantiate Parser object for the initial document.
- Call GetToc method and obtain collection of TocItem objects.
- Check if collection isn’t null (table of contents extraction is supported for the document).
- Iterate through the collection and get page index to extract a page text from the document.
See the following example which shows how to extract table of contents from CHM file.