🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: microsoft.public.fr.dotnet.csharp
Article #1

Document AI with OCR Processor

#1
From: Dhanaraj Sonawane
Date: Mon, 17 Oct 2022 16:47
52 lines
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.
 
Technical Details
Message-ID: <ce5cbfc7-016d-47ef-883e-f5eddc12857bn@googlegroups.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!archive!apf1.newsdeef.eu!not-for-mail

Show Full Headers
Complete Article Headers
Message-ID: <ce5cbfc7-016d-47ef-883e-f5eddc12857bn@googlegroups.com>
Subject: Document AI with OCR Processor
Date: Mon, 17 Oct 2022 16:47:31 +0000
From: Dhanaraj Sonawane <dhanaraj.sonawane1993@gmail.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!archive!apf1.newsdeef.eu!not-for-mail
X-Received: by 2002:a05:620a:4412:b0:6ed:9bf1:dfe9 with SMTP id v18-20020a05620a441200b006ed9bf1dfe9mr8321401qkp.375.1666025251914; Mon, 17 Oct 2022 09:47:31 -0700 (PDT)
X-Received: by 2002:a9d:3eb:0:b0:661:b8f3:1cc1 with SMTP id f98-20020a9d03eb000000b00661b8f31cc1mr5312806otf.380.1666025251572; Mon, 17 Oct 2022 09:47:31 -0700 (PDT)
Newsgroups: microsoft.public.fr.dotnet.csharp
Injection-Info: google-groups.googlegroups.com; posting-host=163.116.205.118; posting-account=8ECGuQkAAAB45SKeorS4Uxt0fraA7-DL
Nntp-Posting-Host: 163.116.205.118
User-Agent: G2/1.0
Mime-Version: 1.0
Injection-Date: Mon, 17 Oct 2022 16:47:31 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 51