The following example shows how to extract table of contents from CHM file:
// Create an instance of Parser classusing(Parserparser=newParser(filePath)){// Check if text extraction is supportedif(!parser.Features.Text){Console.WriteLine("Text extraction isn't supported.");return;}// Check if toc extraction is supportedif(!parser.Features.Toc){Console.WriteLine("Toc extraction isn't supported.");return;}// Get table of contentsIEnumerable<TocItem>toc=parser.GetToc();// Iterate over itemsforeach(TocItemiintoc){// Print the Toc textConsole.WriteLine(i.Text);// Check if page index has a valueif(i.PageIndex==null){continue;}// Extract a page textusing(TextReaderreader=parser.GetText(i.PageIndex.Value)){Console.WriteLine(reader.ReadToEnd());}}}