Simplified ASP.NET Web Forms OCR Demo

Posted on 2016-12-16 Greg

HTML5 is certainly the way of the future, but as many web developers know, adoption can be slow. In many cases, older browsers such as IE8 is still in use enterprise-wide and a lightweight, feature packed solution is still required. LEADTOOLS pioneered lightweight ASP.NET Web Forms imaging years ago and is still a popular choice. Though not as flashy and responsive as HTML5, the heavy-lifting jobs such as Optical Character Recognition (OCR) are still done on the server side.

In the following example, you'll see how to add OCR functionality and image display into your ASP.NET Web Forms application.

ASPX


<%@ Register Assembly="Leadtools.Web" Namespace="Leadtools.Web.Controls" TagPrefix="ltwf" %>
...
<ltwf:WebImageViewer ID="WebImageViewer1" runat="server" />
<asp:Button ID="Button1" runat="server" Text="Recognize" OnClick="Button1_Click" />
<asp:TextBox ID="RecText" runat="server" TextMode="MultiLine"></asp:TextBox>

ASPX Code Behind


IOcrEngine ocrEngine = OcrEngineManager.CreateEngine(OcrEngineType.Professional, true);
ocrEngine.Startup(null, null, null, null);
using (Leadtools.Forms.Ocr.IOcrDocument document = ocrEngine.DocumentManager.CreateDocument())
{
   document.Pages.AddPage(strFileName, null);
   RecText.Text = document.Pages[0].RecognizeText(null);
}
ocrEngine.Shutdown();

For a complete example, check out the original forum post.

LEADTOOLS Blog

LEADTOOLS Powered by Apryse,the Market Leading PDF SDK,All Rights Reserved