Take the following steps to start a project and to add some code that demonstrates how to recognize zones:
Start with the program you created in OCR Tutorial - Working with Pages
This tutorial will save the final result as a PDF file. Therefore, we need to unlock the PDF support first. Modify Form1 constructor to add the following lines just below the first
RasterSupport.Unlock
call:[Visual Basic]
// New code: Unlock the OCR PDF output support RasterSupport.Unlock(RasterSupportType.OcrPlusPdfLeadOutput, "Replace with your own key here");
[C#]
// New code: Unlock the OCR PDF output support RasterSupport.Unlock(RasterSupportType.OcrPlusPdfLeadOutput, "Replace with your own key here");
Drag and drop a button in Form1. Leave the button name as the default "button6", then change the Text property of the button to the following:
Button Text button6 Recognize and Save Add the following code for the button6 (Recognize and Save) control’s
Click
handler:[Visual Basic]
Private Sub button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button6.Click ' Recognize all the pages we have ' Note, we do not have to call AutoZone, the engine ' will check if the page(s) have not been zoned and perfomrs ' auto-zoning for us automatically _ocrDocument.Pages.Recognize(Nothing) ' Save the result as a PDF file Dim pdfFileName As String = "C:\Users\Public\Documents\LEADTOOLS Images\Ocr1.pdf" _ocrDocument.Save(pdfFileName, DocumentFormat.Pdf, Nothing) ' Show the PDF file we just saved System.Diagnostics.Process.Start(pdfFileName) End Sub
[C#]
private void button6_Click(object sender, EventArgs e) { // Recognize all the pages we have // Note, we do not have to call AutoZone, the engine // will check if the page(s) have not been zoned and perfomrs // auto-zoning for us automatically _ocrDocument.Pages.Recognize(document, null); // Save the result as a PDF file string pdfFileName = @"C:\Users\Public\Documents\LEADTOOLS Images\Ocr1.pdf"; _ocrDocument.Save(pdfFileName, DocumentFormat.Pdf, null); // Show the PDF file we just saved System.Diagnostics.Process.Start(pdfFileName); }
Build, and Run the program to test it. You can click the buttons in the following order to create the PDF file "Startup", "Add Page", "Save and Recognize", "Shutdown".
Save this project to use for testing other code samples.
Reference
OCR Tutorial - Working with PagesOCR Tutorial - Adding and Painting Zones
OCR Tutorial - Working with Recognition Results
OCR Tutorial - Scanning to Searchable PDF
Introduction
Getting Started (Guide to Example Programs)
LEADTOOLS OCR .NET Assemblies
Programming with LEADTOOLS .NET OCR
An Overview of OCR Recognition Modules
Creating an OCR Engine Instance
Starting and Shutting Down the OCR Engine
OCR Spell Language Dictionaries
Working with OCR Languages
Working With OCR User Dictionaries
Working with OCR Pages
Working with OCR Zones
Recognizing OCR Pages
OCR Confidence Reporting
Using OMR in LEADTOOLS .NET OCR
OCR Languages and Spell Checking
OCR Engine-Specific Settings