Provides support for OCR functionality in LEADTOOLS.
Syntax
Visual Basic (Declaration) | |
---|
Public Interface IOcrEngine |
Visual Basic (Usage) | Copy Code |
---|
Dim instance As IOcrEngine
|
C# | |
---|
public interface IOcrEngine |
C++/CLI | |
---|
public interface class IOcrEngine |
Example
The following example will convert an image file to a PDF document.
Visual Basic | Copy Code |
---|
Public Sub OcrEngineExample()
RasterSupport.Unlock(RasterSupportType.Document, "Replace with your own key here")
RasterSupport.Unlock(RasterSupportType.OcrPlus, "Replace with your own key here")
RasterSupport.Unlock(RasterSupportType.OcrPlusPdfLeadOutput, "Replace with your own key here")
Using ocrEngine As IOcrEngine = OcrEngineManager.CreateEngine(OcrEngineType.Plus, False)
ocrEngine.Startup(Nothing, Nothing, Nothing, Nothing)
Dim tifFileName As String = LeadtoolsExamples.Common.ImagesPath.Path + "Ocr1.tif"
Dim pdfFileName As String = LeadtoolsExamples.Common.ImagesPath.Path + "Ocr1.pdf"
Using ocrDocument As IOcrDocument = ocrEngine.DocumentManager.CreateDocument()
Dim ocrPage As IOcrPage = ocrDocument.Pages.AddPage(tifFileName, Nothing)
ocrPage.AutoZone(Nothing)
ocrPage.Recognize(Nothing)
ocrDocument.Save(pdfFileName, DocumentFormat.Pdf, Nothing)
End Using
ocrEngine.Shutdown()
End Using
End Sub |
C# | Copy Code |
---|
public void OcrEngineExample() { // Unlock the support needed for LEADTOOLS Plus OCR engine RasterSupport.Unlock(RasterSupportType.Document, "Replace with your own key here"); RasterSupport.Unlock(RasterSupportType.OcrPlus, "Replace with your own key here"); RasterSupport.Unlock(RasterSupportType.OcrPlusPdfLeadOutput, "Replace with your own key here"); // Create an instance of the engine using(IOcrEngine ocrEngine = OcrEngineManager.CreateEngine(OcrEngineType.Plus, false)) { // Start the engine using default parameters ocrEngine.Startup(null, null, null, null); string tifFileName = LeadtoolsExamples.Common.ImagesPath.Path + "Ocr1.tif"; string pdfFileName = LeadtoolsExamples.Common.ImagesPath.Path + "Ocr1.pdf"; // Create an OCR document using(IOcrDocument ocrDocument = ocrEngine.DocumentManager.CreateDocument()) { // Add a page to the document IOcrPage ocrPage = ocrDocument.Pages.AddPage(tifFileName, null); // Recognize the page // Note, Recognize can be called without calling AutoZone or manually adding zones. The engine will // check and automatically auto-zones the page ocrPage.AutoZone(null); ocrPage.Recognize(null); // Save the document we have as PDF ocrDocument.Save(pdfFileName, DocumentFormat.Pdf, null); } // Shutdown the engine // Note: calling Dispose will also automatically shutdown the engine if it has been started ocrEngine.Shutdown(); } } |
Remarks
Requirements
Target Platforms: Microsoft .NET Framework 3.0, Windows XP, Windows Server 2003 family, Windows Server 2008 family
See Also