Exemple #1
0
        public void TestExtractTemplateRegions()
        {
            FileInfo pdfFile = new FileInfo("OLPDFS\\43159363.pdf");
            var      pngFile = CloudOcrService.ConvertPdfToPng(pdfFile);
            var      result  = CloudOcrService.ExtractRegionFromPng(pngFile, _template.Regions.First(x => x.RegionName == OcrRegionName.CaseNumber));

            Assert.AreEqual(result, "");
        }
Exemple #2
0
        static void Main(string[] args)
        {
            var template = new OcrTemplate
            {
                CourtId = 1,
                DocumentType = "Case Management Statement",
                OcrTemplateId = 1
            };

            var caseNumberRegion = new OcrRegion(1561, 957, 2291, 1158, OcrRegionName.CaseNumber);
            var plaintiffRegion = new OcrRegion(150, 830, 1640, 1010, OcrRegionName.Plaintiff);
            var attorneyRegion = new OcrRegion(150, 200, 1640, 590, OcrRegionName.Attorney);
            var hearingDateRegion = new OcrRegion(150, 1220, 2291, 1350, OcrRegionName.HearingDate);
            template.Regions.Add(caseNumberRegion);
            template.Regions.Add(plaintiffRegion);
            template.Regions.Add(attorneyRegion);
            template.Regions.Add(hearingDateRegion);

            FileInfo pdfFile = new FileInfo("OLPDFS\\43159219.pdf");


            var pngFile = CloudOcrService.ConvertPdfToPng(pdfFile);

            var results = CloudOcrService.ExtractTemplateFromPdfAsync(pdfFile, template);

            foreach (var str in results.Result)
            {
                
            }
            Console.WriteLine(results.Result.Select(s => s));
            foreach (var region in template.Regions)
            {
                Console.WriteLine(region.RegionName.ToString() + ": " + CloudOcrService.ExtractRegionFromPng(pngFile, region));
            }
            Console.ReadLine();
        }