Beispiel #1
0
 public static async Task<IEnumerable<string>> ExtractTemplateFromPdfAsync(FileInfo pdfFile, OcrTemplate ocrTemplate)
 {
     FileInfo pngFile = ConvertPdfToPng(pdfFile);
     List<string> results = new List<string>();
     foreach (var region in ocrTemplate.Regions)
     {
         var xml = await CallOcrWebServiceAsync(pngFile, region.TopLeftX, region.TopLeftY, region.BottomRightX, region.BottomRightY);
         results.Add(xml);
     }            
     return results;
 }
Beispiel #2
0
 public void TestInitialize()
 {
     _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);
 }
Beispiel #3
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();
        }
Beispiel #4
0
        public static async Task <IEnumerable <string> > ExtractTemplateFromPdfAsync(FileInfo pdfFile, OcrTemplate ocrTemplate)
        {
            FileInfo      pngFile = ConvertPdfToPng(pdfFile);
            List <string> results = new List <string>();

            foreach (var region in ocrTemplate.Regions)
            {
                var xml = await CallOcrWebServiceAsync(pngFile, region.TopLeftX, region.TopLeftY, region.BottomRightX, region.BottomRightY);

                results.Add(xml);
            }
            return(results);
        }