using System;
using System.Collections.Generic;
//Use following namespace to extract text from scanned PDF 
using Aspose.OCR;


namespace ExtractTextFromScannedPDFFile
{
    class Program
    {
        static void Main(string[] args)
        {
            //Set license before extracting text from scanned PDF file
            Aspose.OCR.License AsposeOCRLicense = new Aspose.OCR.License();
            AsposeOCRLicense.SetLicense(@"c:\asposelicense\license.lic");

            //create AsposeOcr object
            AsposeOcr ScannedPDFFile = new AsposeOcr();

            //set recognition settings 
            DocumentRecognitionSettings RecognitionSettings = new DocumentRecognitionSettings();
            RecognitionSettings.StartPage = 1;
            RecognitionSettings.PagesNumber = 3;
            //when set true, improves accuracy but reduces speed
            RecognitionSettings.DetectAreas = false;

            //extract text from specified pages
            List<RecognitionResult> ExtractedResults = ScannedPDFFile.RecognizePdf("InputScannedPDFFile.pdf", RecognitionSettings);

            //fetch extracted text of each page
            int PageCounter = 1;
            foreach(RecognitionResult SinglePage in ExtractedResults)
            {
                Console.WriteLine("Page: {0},  Extracted Text:{1}", PageCounter, SinglePage.RecognitionText);
                PageCounter++;
            }
        }
    }
}