LEADTOOLS WCF OCR (Leadtools.Services.Forms.ServiceContracts assembly)
LEAD Technologies, Inc

IOcrService Interface

Example 





Members 
Represents the WCF Service contract for the OCR service.
Object Model
IOcrService Interface
Syntax
[ServiceContractAttribute(Name="IOcrService", Namespace="http://Leadtools.Services.Forms.ServiceContracts/2009/01")]
public interface IOcrService 
'Declaration
 
<ServiceContractAttribute(Name="IOcrService", Namespace="http://Leadtools.Services.Forms.ServiceContracts/2009/01")>
Public Interface IOcrService 
'Usage
 
Dim instance As IOcrService
[ServiceContractAttribute(Name="IOcrService", Namespace="http://Leadtools.Services.Forms.ServiceContracts/2009/01")]
public interface IOcrService 
function Leadtools.Services.Forms.ServiceContracts.IOcrService() 
[ServiceContractAttribute(Name="IOcrService", Namespace="http://Leadtools.Services.Forms.ServiceContracts/2009/01")]
public interface class IOcrService 
Remarks

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

Example
 
Public Sub DocumentConvertOptionsExample()
      Dim client As OcrServiceClient = New OcrServiceClient()
      Dim sourceBinaryData As RawBinaryData = New RawBinaryData()
      sourceBinaryData.Data = File.ReadAllBytes(Path.Combine(LEAD_VARS.ImagesDir, "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(Path.Combine(LEAD_VARS.ImagesDir, "clean.txt"), (TryCast(response.Destination, RawBinaryData)).Data)
         End If
      End If

      client.Close()
   End Sub

Public NotInheritable Class LEAD_VARS
   Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
public void DocumentConvertOptionsExample()
   {
      OcrServiceClient client = new OcrServiceClient();
      RawBinaryData sourceBinaryData = new RawBinaryData();
      sourceBinaryData.Data = File.ReadAllBytes(Path.Combine(LEAD_VARS.ImagesDir, "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(Path.Combine(LEAD_VARS.ImagesDir,"clean.txt"), (response.Destination as RawBinaryData).Data);
      }

      client.Close();
   }

static class LEAD_VARS
{
   public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";
}
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

IOcrService Members
Leadtools.Services.Forms.ServiceContracts Namespace

Represents the WCF Service contract for the OCR service.
Object Model
IOcrService Interface
Syntax
[ServiceContractAttribute(Name="IOcrService", Namespace="http://Leadtools.Services.Forms.ServiceContracts/2009/01")]
public interface IOcrService 
'Declaration
 
<ServiceContractAttribute(Name="IOcrService", Namespace="http://Leadtools.Services.Forms.ServiceContracts/2009/01")>
Public Interface IOcrService 
'Usage
 
Dim instance As IOcrService
[ServiceContractAttribute(Name="IOcrService", Namespace="http://Leadtools.Services.Forms.ServiceContracts/2009/01")]
public interface IOcrService 
function Leadtools.Services.Forms.ServiceContracts.IOcrService() 
[ServiceContractAttribute(Name="IOcrService", Namespace="http://Leadtools.Services.Forms.ServiceContracts/2009/01")]
public interface class IOcrService 
Remarks

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

Example
 
Public Sub DocumentConvertOptionsExample()
      Dim client As OcrServiceClient = New OcrServiceClient()
      Dim sourceBinaryData As RawBinaryData = New RawBinaryData()
      sourceBinaryData.Data = File.ReadAllBytes(Path.Combine(LEAD_VARS.ImagesDir, "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(Path.Combine(LEAD_VARS.ImagesDir, "clean.txt"), (TryCast(response.Destination, RawBinaryData)).Data)
         End If
      End If

      client.Close()
   End Sub

Public NotInheritable Class LEAD_VARS
   Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
public void DocumentConvertOptionsExample()
   {
      OcrServiceClient client = new OcrServiceClient();
      RawBinaryData sourceBinaryData = new RawBinaryData();
      sourceBinaryData.Data = File.ReadAllBytes(Path.Combine(LEAD_VARS.ImagesDir, "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(Path.Combine(LEAD_VARS.ImagesDir,"clean.txt"), (response.Destination as RawBinaryData).Data);
      }

      client.Close();
   }

static class LEAD_VARS
{
   public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";
}
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

IOcrService Members
Leadtools.Services.Forms.ServiceContracts Namespace

 

 


Products | Support | Contact Us | Copyright Notices

© 2006-2012 All Rights Reserved. LEAD Technologies, Inc.

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