Gets or sets a list of additional files that need to be created by the user.
Syntax
Return Value
A
DocumentFiles object that contains a list of additional files that need to be created by the user.
Example
Visual Basic | Copy Code |
---|
Private Sub Replace(ByVal docFileName As String, ByVal source As String, ByVal destination As String)
Dim streamReader As StreamReader
streamReader = File.OpenText(docFileName)
Dim contents As String = streamReader.ReadToEnd()
streamReader.Close()
Dim streamWriter As StreamWriter = File.CreateText(docFileName)
streamWriter.Write(contents.Replace(source, destination))
streamWriter.Close()
End Sub
Public Sub DocumentFilesExample()
Dim client As OcrServiceClient = New OcrServiceClient()
Dim sourceBinaryData As RawBinaryData = New RawBinaryData()
sourceBinaryData.Data = File.ReadAllBytes(LeadtoolsExamples.Common.ImagesPath.Path & "clean.tif")
Dim convertOptions As DocumentConvertOptions = New DocumentConvertOptions()
convertOptions.Source = sourceBinaryData
convertOptions.Destination = Nothing
convertOptions.Format = OcrDocumentFormatType.Html
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
Dim outFileName As String = LeadtoolsExamples.Common.ImagesPath.Path & "clean.html"
If TypeOf response.Destination Is RawBinaryData Then
File.WriteAllBytes(outFileName, (TryCast(response.Destination, RawBinaryData)).Data)
If Not response.Files Is Nothing Then
Replace(outFileName, "Leadtools_Rename_This", Path.GetFileNameWithoutExtension(outFileName))
Dim directory As String = Path.GetDirectoryName(outFileName) & "\" & Path.GetFileNameWithoutExtension(outFileName) & "_Dir"
System.IO.Directory.CreateDirectory(directory)
For Each info As DocumentFileInfo In files
File.WriteAllBytes(directory & "\" & info.FileName, info.FileData.Data)
Next info
End If
End If
End If
client.Close()
End Sub |
C# | Copy Code |
---|
private void Replace(string docFileName, string source, string destination) { // Open a file for reading StreamReader streamReader; streamReader = File.OpenText(docFileName); // read the entire file into a string string contents = streamReader.ReadToEnd(); streamReader.Close(); StreamWriter streamWriter = File.CreateText(docFileName); streamWriter.Write(contents.Replace(source, destination)); streamWriter.Close(); } public void DocumentFilesExample() { 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.Html; 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) { string outFileName = LeadtoolsExamples.Common.ImagesPath.Path + "clean.html"; if (response.Destination is RawBinaryData) { File.WriteAllBytes(outFileName, (response.Destination as RawBinaryData).Data); if (response.Files != null) { Replace(outFileName, "Leadtools_Rename_This", Path.GetFileNameWithoutExtension(outFileName)); string directory = Path.GetDirectoryName(outFileName) + "\\" + Path.GetFileNameWithoutExtension(outFileName) + "_Dir"; Directory.CreateDirectory(directory); foreach (DocumentFileInfo info in files) { File.WriteAllBytes(directory + "\\" + info.FileName, info.FileData.Data); } } } } client.Close(); } |
Remarks
Requirements
Target Platforms: Microsoft .NET Framework 3.0, Windows XP, Windows Server 2003 family, Windows Server 2008 family
See Also