GroupDocsGists
10/24/2017 - 1:18 PM

Examples-CSharp-GroupDocs.Text.Examples.CSharp-Utilities-ExtractText-ExtractText.cs

// For complete examples and data files, please go to https://github.com/groupdocs-text/GroupDocs.Text-for-.NET
int linesPerPage = Console.WindowHeight;
ExtractorFactory factory = new ExtractorFactory();

TextExtractor extractor = formatted
    ? factory.CreateFormattedTextExtractor(fileName)
    : factory.CreateTextExtractor(fileName);
if (extractor == null)
{
    Console.WriteLine("The document's format is not supported");
    return;
}

try
{
    string line = null;
    do
    {
        Console.Clear();
        Console.WriteLine("{0}", fileName);

        int lineNumber = 0;
        do
        {
            line = extractor.ExtractLine();
            lineNumber++;
            if (line != null)
            {
                Console.WriteLine(line);
            }
        }
        while (line != null && lineNumber < linesPerPage);

        Console.WriteLine();
        Console.WriteLine("Press Esc to exit or any other key to move to the next page");
    }
    while (line != null && Console.ReadKey().Key != ConsoleKey.Escape);
}
finally
{
    extractor.Dispose();
}