Leadtools.Services.Forms.ServiceContracts Requires Document/Medical product license | Send comments on this topic. | Back to Introduction - All Topics | Help Version 16.5.9.25
IOcrService Interface
See Also  Members   Example
Leadtools.Services.Forms.ServiceContracts Namespace : IOcrService Interface



Represents the WCF Service contract for the OCR service.

Syntax

Visual Basic (Declaration) 
<ServiceContractAttribute(Name="IOcrService", Namespace="http://Leadtools.Services.Forms.ServiceContracts/2009/01")>
Public Interface IOcrService 
Visual Basic (Usage)Copy Code
Dim instance As IOcrService
C# 
[ServiceContractAttribute(Name="IOcrService", Namespace="http://Leadtools.Services.Forms.ServiceContracts/2009/01")]
public interface IOcrService 
C++/CLI 
[ServiceContractAttribute(Name="IOcrService", Namespace="http://Leadtools.Services.Forms.ServiceContracts/2009/01")]
public interface class IOcrService 

Example

Visual BasicCopy Code
Public Sub DocumentConvertOptionsExample()
  Dim client As OcrServiceClient = New OcrServiceClient()
  Dim sourceBinaryData As RawBinaryData = New RawBinaryData()
  sourceBinaryData.Data = File.ReadAllBytes(LeadtoolsExamples.Common.ImagesPath.Path & "clean.tif")

  ' set the document convertion options
  Dim convertOptions As DocumentConvertOptions = New DocumentConvertOptions()

  convertOptions.Source = sourceBinaryData
  convertOptions.Destination = Nothing
  convertOptions.Format = OcrDocumentFormatType.TextAnsi
  convertOptions.FirstPageNumber = 1
  convertOptions.LastPageNumber = 1
  Dim files As DocumentFiles = Nothing

  Dim request As RecognizeRequest = New RecognizeRequest()
  request.ConvertOptions = convertOptions

  Dim response As RecognizeResponse = client.Recognize(request)

  If Not response.Destination Is Nothing Then
    If TypeOf response.Destination Is RawBinaryData Then
       File.WriteAllBytes(LeadtoolsExamples.Common.ImagesPath.Path & "clean.txt", (TryCast(response.Destination, RawBinaryData)).Data)
    End If
  End If

  client.Close()
End Sub
C#Copy Code
public void DocumentConvertOptionsExample() 

   OcrServiceClient client = new OcrServiceClient(); 
   RawBinaryData sourceBinaryData = new RawBinaryData(); 
   sourceBinaryData.Data = File.ReadAllBytes(LeadtoolsExamples.Common.ImagesPath.Path + "clean.tif"); 
 
   // set the document convertion options 
   DocumentConvertOptions convertOptions = new DocumentConvertOptions(); 
 
   convertOptions.Source = sourceBinaryData; 
   convertOptions.Destination = null; 
   convertOptions.Format = OcrDocumentFormatType.TextAnsi; 
   convertOptions.FirstPageNumber = 1; 
   convertOptions.LastPageNumber = 1; 
   DocumentFiles files = null; 
 
   RecognizeRequest request = new RecognizeRequest(); 
   request.ConvertOptions = convertOptions; 
 
   RecognizeResponse response = client.Recognize(request); 
 
   if (response.Destination != null) 
   { 
      if(response.Destination is RawBinaryData) 
         File.WriteAllBytes(LeadtoolsExamples.Common.ImagesPath.Path + "clean.txt", (response.Destination as RawBinaryData).Data); 
   } 
 
   client.Close(); 
}

Remarks

You can use the Recognize method to convert an image on a disk to a final document with any of the document formats supported by the specified engine.

Requirements

Target Platforms: Microsoft .NET Framework 3.0, Windows XP, Windows Server 2003 family, Windows Server 2008 family

See Also

Applications developed with LEADTOOLS WCF components require runtime licenses. Server licensing is required for applications on a server. For more information, refer to: Imaging Pro/Document/Medical Features