Products | Support | Email a link to this topic. | Send comments on this topic. | Back to Introduction | Help Version 19.0.6.21
|
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
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:
ButtonTextbutton6Recognize and Save
Add the following code for the button6 (Recognize and Save) Click
handler:
[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 perform
// auto-zoning for us automatically
_ocrDocument.Pages.Recognize(null);
// Prompt the user for a PDF file
string fileName = null;
using (SaveFileDialog dlg = new SaveFileDialog())
{
dlg.Filter = "PDF files|*.pdf|All files|*.*";
dlg.DefaultExt = "pdf";
if (dlg.ShowDialog(this) == DialogResult.OK)
fileName = dlg.FileName;
}
if (fileName == null)
return;
// Save the result as a PDF file
_ocrDocument.Save(fileName, DocumentFormat.Pdf, null);
// Show the PDF file we just saved
System.Diagnostics.Process.Start(fileName);
}
[Visual Basic]
Private Sub button6_Click(sender As Object, e As EventArgs)
' 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 perform
' auto-zoning for us automatically
_ocrDocument.Pages.Recognize(Nothing)
' Prompt the user for a PDF file
Dim fileName As String = Nothing
Using dlg As New SaveFileDialog()
dlg.Filter = "PDF files|*.pdf|All files|*.*"
dlg.DefaultExt = "pdf"
If (dlg.ShowDialog(Me) = DialogResult.OK) Then
fileName = dlg.FileName
End If
End Using
If IsNothing(fileName) Then Return
' Save the result as a PDF file
_ocrDocument.Save(fileName, DocumentFormat.Pdf, Nothing)
' Show the PDF file we just saved
System.Diagnostics.Process.Start(fileName)
End Sub
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.
OCR Tutorial - Working with Pages
OCR 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
Multi-Threading with LEADTOOLS OCR
OCR Spell Language Dictionaries
Working with OCR Languages
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