Thread View: microsoft.public.fr.dotnet.csharp
1 messages
1 total messages
Started by Dhanaraj Sonawane
Mon, 17 Oct 2022 16:47
Document AI with OCR Processor
Author: Dhanaraj Sonawane
Date: Mon, 17 Oct 2022 16:47
Date: Mon, 17 Oct 2022 16:47
52 lines
2948 bytes
2948 bytes
I need code level details for implementing Document AI in Console Application(C#).
It will very help full for me.
Actually i have snippet code for Document AI in c# , but its not working.
Code is share for reference.
try
{
//Generate a document
string pdfFilePath = "C:\\Dhanaraj\\- - - - - PD-INVOICES-PDDemo.pdf";
var bytes = Encoding.UTF8.GetBytes(pdfFilePath);
//string pdfFilePath = "path-as-before";
//var bytes = File.ReadAllBytes(pdfFilePath);
//ByteString content = ByteString.CopyFrom(bytes);
ByteString content = ByteString.CopyFrom(bytes);
// Create client
DocumentProcessorServiceClient documentProcessorServiceClient = await DocumentProcessorServiceClient.CreateAsync();
// Initialize request argument(s)
ProcessRequest request = new ProcessRequest
{
ProcessorsName = ProcessorName.FromProjectLocationProcessor("mindful-silo-351415", "us", "a072a02fe917a81b"),
SkipHumanReview = false,
InlineDocument = new Google.Cloud.DocumentAI.V1.Document(),
RawDocument = new RawDocument(),
};
request.RawDocument.MimeType = "application/pdf";
request.RawDocument.Content = content;
// Make the request
ProcessResponse response = await documentProcessorServiceClient.ProcessDocumentAsync(request);
Google.Cloud.DocumentAI.V1.Document docResponse = response.Document;
Console.WriteLine(docResponse.Text);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
Thanks in advance.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads