1

I am using IronOCR OCR Library to read text from a particular area within a PNG image which goes fine. However, I need to do the same with a directory/folder and save it to a directory/folder.

Here's the code that I am currently using

public void workOCR()
{
    var ocr = new AutoOcr();
    var Area = new Rectangle()
    {
        X = 1367,
        Y = 420,
        Height = 57,
        Width = 411
    };
    var result = ocr.Read(@"C:\Users\fasihullahkhan\Desktop\pdftopng\page3.png", Area);
    label1.Text = result.Text;
}

What I want to do is specify a directory like this:

ocr.Read(@"C:\Users\fasihullahkhan\Desktop\pdftopng\", Area);

From within a loop, but I don't know how. Please help.

theLuckyOne
  • 262
  • 3
  • 20
  • 2
    If you find all `*.png` files of a directory, you can solve the problem. There are a couple of posts about this topic. For example take a look at [this post](https://stackoverflow.com/questions/14877237/getting-all-file-names-from-a-folder-using-c-sharp). – Reza Aghaei Dec 24 '18 at 03:10
  • I have tried that, that's why I have explicitly asked to devise a method that will loop through the directory within the realms of IronOCR. Because the first argument of `ocr.Read()` does not accept an array. –  Dec 24 '18 at 03:20
  • 1
    First of all, it does. Look at [here](https://ironsoftware.com/csharp/ocr/object-reference/html/M_IronOcr_AutoOcr_Read_2.htm). Second, if you want to use the overload which accepts filename and rectangle, you can use a for loop and for each element of the array, pass it to `Read` method which accepts filename and the rectangle. – Reza Aghaei Dec 24 '18 at 03:26
  • 1
    You also can use this overload [`AdvancedOcr.ReadMultiThreaded`](https://ironsoftware.com/csharp/ocr/object-reference/html/M_IronOcr_AdvancedOcr_ReadMultiThreaded_4.htm) which accepts a list of files, a rectangle and maximum number of concurrent threads. – Reza Aghaei Dec 24 '18 at 03:34

0 Answers0