Gets or sets a list of additional files that need to be created by the user.
[DataMemberAttribute(Name="Files", IsRequired=true)]
public DocumentFiles Files { get; set; }
<DataMemberAttribute(Name="Files", IsRequired=True)>
Public Property Files As Leadtools.Services.Forms.Datacontracts.DocumentFiles
[DataMemberAttribute(Name="Files", IsRequired=true)]
public:
property Leadtools.Services.Forms.Datacontracts.DocumentFiles^ Files {
Leadtools.Services.Forms.Datacontracts.DocumentFiles^ get();
void set ( Leadtools.Services.Forms.Datacontracts.DocumentFiles^ );
}
A DocumentFiles object that contains a list of additional files that need to be created by the user.
You need to go through this list and write each file using the DocumentFileInfo.FileName and DocumentFileInfo.FileData properties
using Leadtools.Services;
using Leadtools.Services.Forms.ServiceContracts;
using Leadtools.Services.Forms.ServiceImplementations;
//using Leadtools.Services.Forms.DataContractsExamples.localhost;
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(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.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 = Path.Combine(LEAD_VARS.ImagesDir, "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();
}
static class LEAD_VARS
{
public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";
}
Imports Leadtools.Services
Imports Leadtools.Services.Forms.ServiceContracts
Imports Leadtools.Services.Forms.ServiceImplementations
'using Leadtools.Services.Forms.DataContractsExamples.localhost;
Private Sub Replace(ByVal docFileName As String, ByVal source As String, ByVal destination As String)
' Open a file for reading
Dim streamReader As StreamReader
streamReader = File.OpenText(docFileName)
' read the entire file into a string
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(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.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 = Path.Combine(LEAD_VARS.ImagesDir, "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
Public NotInheritable Class LEAD_VARS
Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
Raster .NET | C API | C++ Class Library | JavaScript HTML5
Document .NET | C API | C++ Class Library | JavaScript HTML5
Medical .NET | C API | C++ Class Library | JavaScript HTML5
Medical Web Viewer .NET
Your email has been sent to support! Someone should be in touch! If your matter is urgent please come back into chat.
Chat Hours:
Monday - Friday, 8:30am to 6pm ET
Thank you for your feedback!
Please fill out the form again to start a new chat.
All agents are currently offline.
Chat Hours:
Monday - Friday
8:30AM - 6PM EST
To contact us please fill out this form and we will contact you via email.