Converts an image to a document in the specified document format.
Syntax
Parameters
- uri
- The URI of image.
- username
- The username who has privileges on the the specified URI. Must be passed as (domain/username).
- password
- The password for the specified user.
- format
- The output document format.
Return Value
A stream that contains the document data.
Example
This example will convert a TIF file in a sharepoint to text and save it to disk.
Visual Basic | Copy Code |
---|
Public Sub RecognizeImageExample()
Dim buffer As Byte() = New Byte(1024 * 64 - 1){}
Dim totalBytesRead As Integer = 0
Dim memoryStream As MemoryStream = New MemoryStream()
Dim client As OcrServiceClient = New OcrServiceClient()
Dim stream As Stream = client.RecognizeImage("http://sp2007ep/Ocr/Shared%20Documents/OCR.TIF", "username", "password", OcrDocumentFormatType.TextAnsi)
Dim bytesRead As Integer
Do While (bytesRead = stream.Read(buffer, 0, buffer.Length)) > 0
totalBytesRead += bytesRead
memoryStream.Write(buffer, 0, bytesRead)
Loop
File.WriteAllBytes(LeadtoolsExamples.Common.ImagesPath.Path & "ocr.txt", memoryStream.ToArray())
client.Close()
End Sub |
C# | Copy Code |
---|
public void RecognizeImageExample() { byte[] buffer = new byte[1024 * 64]; int totalBytesRead = 0; MemoryStream memoryStream = new MemoryStream(); OcrServiceClient client = new OcrServiceClient(); Stream stream = client.RecognizeImage(@"http://sp2007ep/Ocr/Shared%20Documents/OCR.TIF", "username", "password", OcrDocumentFormatType.TextAnsi); int bytesRead; while ((bytesRead = stream.Read(buffer, 0, buffer.Length)) > 0) { totalBytesRead += bytesRead; memoryStream.Write(buffer, 0, bytesRead); } File.WriteAllBytes(LeadtoolsExamples.Common.ImagesPath.Path + "ocr.txt", memoryStream.ToArray()); client.Close(); } |
Remarks
Requirements
Target Platforms: Microsoft .NET Framework 3.0, Windows XP, Windows Server 2003 family, Windows Server 2008 family
See Also