This implementation is based on Aspose.OCR for .NET on-premise API. Although it requires a valid license file, you can always request a temporal license for a month to evaluate.
C#
usingGroupDocs.Redaction.Integration.Ocr;publicclassAsposeOCRStandaloneConnector:IOcrConnector{publicAsposeOCRStandaloneConnector(stringlicenseFile){varlic=newAspose.OCR.License();lic.SetLicense(licenseFile);}publicRecognizedImageRecognize(StreamimageStream){try{using(MemoryStreammemStream=newMemoryStream()){imageStream.CopyTo(memStream);varapi=newAspose.OCR.AsposeOcr();varrectangles=api.GetRectangles(memStream,Aspose.OCR.AreasType.LINES,false);varresult=api.RecognizeImage(memStream,newAspose.OCR.RecognitionSettings(){Language=Aspose.OCR.Language.Eng,RecognitionAreas=rectangles});returnCreateDtoFromResponse(result);}}catch(Exceptionex){Console.WriteLine("Aspose.OCR for Cloud Recognition failed: {0}",ex.ToString());}returnnewRecognizedImage(newList<TextLine>());}protectedvirtualRecognizedImageCreateDtoFromResponse(Aspose.OCR.RecognitionResultresult){List<TextLine>lines=newList<TextLine>();for(inti=0;i<result.RecognitionAreasText.Count;i++){varfragments=RegularTextLine.SplitToFragments(result.RecognitionAreasText[i].Trim('\r','\n'),result.RecognitionAreasRectangles[i]);lines.Add(newTextLine(fragments));}returnnewRecognizedImage(lines);}}
First, we identify rectangle areas of text using GetRectangles() method with Aspose.OCR.AreasType.LINES option. With this option, you will get a rectangle for every line of text, but you will have to split it to words.
Along with full featured .NET library we provide simple, but powerful free Apps.
You are welcome to perform redactions for various document formats like PDF, DOC, DOCX, PPT, PPTX, XLS, XLSX, Emails and more with our free online Free Online Document Redaction App.
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.