using GroupDocs.Search;
using GroupDocs.Search.Common;
using GroupDocs.Search.Options;
using GroupDocs.Search.Results;

namespace ExportIndexedDocumentstoHTMLUsingCSharp
{
    internal class Program
    {
        static void Main(string[] args)
        {
            // Apply the license to remove the restrictions
            // imposed by the Search library
            License lic = new License();
            lic.SetLicense(@"GroupDocs.Search.lic");

            string indexFolder = @"d:\MyIndex\";
            string documentsFolder = @"d:\MyDocuments\";

            // Creating an index settings instance
            IndexSettings settings = new IndexSettings();
            // Enabling storage of extracted text in the index
            settings.TextStorageSettings = new TextStorageSettings(Compression.High); 

            // Creating an index in the specified folder
            Index index = new Index(indexFolder, settings);

            // Indexing documents from the specified folder
            index.Add(documentsFolder);

            // Getting list of indexed documents
            DocumentInfo[] documents = index.GetIndexedDocuments();

            // Getting a document text
            if (documents.Length > 0)
            {
                DocumentInfo document = documents[0];

                // Output to a file
                FileOutputAdapter fileOutputAdapter = new FileOutputAdapter(
                                          OutputFormat.Html, @"d:\Text.html");
                index.GetDocumentText(document, fileOutputAdapter);
            }
        }
    }
}