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.SetLicense
call:
[Visual Basic]
// New code: Unlock the OCR PDF output support
RasterSupport.SetLicense(RasterSupportType.OcrProfessionalPdfLeadOutput, "Replace with your own key here");
[C#]
// New code: Unlock the OCR PDF output support
RasterSupport.SetLicense(RasterSupportType.OcrProfessionalPdfLeadOutput, "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(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.