ExtractText
TocItem.ExtractText method
Extracts a text from the document to which TocItem
object refers.
public virtual TextReader ExtractText()
Return Value
An instance of TextReader class with the extracted text.
Examples
The following example how to extract a text by the an item of table of contents:
// Create an instance of Parser class
using (Parser parser = new Parser(Constants.SampleDocxWithToc))
{
// Get table of contents
IEnumerable<TocItem> tocItems = parser.GetToc();
// Check if toc extraction is supported
if (tocItems == null)
{
Console.WriteLine("Table of contents extraction isn't supported");
}
// Iterate over items
foreach (TocItem tocItem in tocItems)
{
// Print the text of the chapter
using (TextReader reader = tocItem.ExtractText())
{
Console.WriteLine("----");
Console.WriteLine(reader.ReadToEnd());
}
}
}
See Also
- class TocItem
- namespace GroupDocs.Parser.Data
- assembly GroupDocs.Parser