public void Execute(Arguments arguments) { manager = AbbyyManager.Instance; System.Drawing.Rectangle rectangle = !arguments.Relative.Value ? arguments.Area.Value : arguments.Area.Value.ToAbsoluteCoordinates(); System.Drawing.Bitmap partOfScreen = RobotWin32.GetPartOfScreen(rectangle); IEngine engine = manager.Engine; DocumentProcessingParams processingParams = engine.CreateDocumentProcessingParams(); RecognizerParams recognizingParams = processingParams.PageProcessingParams.RecognizerParams; recognizingParams.SetPredefinedTextLanguage(arguments.Language.Value); engine.LoadPredefinedProfile(AbbyyManager.TextAccuracyProfile); FRDocument imageDocument = engine.CreateFRDocument(); using (System.IO.MemoryStream stream = new System.IO.MemoryStream()) { partOfScreen.Save(stream, System.Drawing.Imaging.ImageFormat.Bmp); stream.Position = 0; IReadStream imageStream = new StreamNet2AbbyyAdapter(stream); imageDocument.AddImageFileFromStream(imageStream); } imageDocument.Process(processingParams); Scripter.Variables.SetVariableValue(arguments.Result.Value, new TextStructure(imageDocument.PlainText.Text)); }
public FineReaderDocument CreateDocument(Stream stream) { stream.Position = 0; IReadStream abbyyStream = new StreamNet2AbbyyAdapter(stream); FineReaderDocument document = CreateDocument(); document.Document.AddImageFileFromStream(abbyyStream, PrepareMode: prepareImageMode); return(document); }