title: Text extraction from a PDF using iText7. How to improve its performance?
body: <p>Currently, I use this code to extract text from a Rectangle (area).</p>
  
  <pre><code>public static class ReaderExtensions
  {
      public static string ExtractText(this PdfPage page, Rectangle rect)
      {
          var filter = new IEventFilter[1];
          filter[0] = new TextRegionEventFilter(rect);
          var filteredTextEventListener = new FilteredTextEventListener(new LocationTextExtractionStrategy(), filter);
          var str = PdfTextExtractor.GetTextFromPage(page, filteredTextEventListener);
          return str;
      }
  }
  </code></pre>
  
  <p>It works, but I don't know if it's the best way to do it.</p>
  
  <p>Also, I wonder if the GetTextFromPage could be improved by the iText team to increase its performance, since I'm processing hundreds of pages in big PDFs and it usually takes more than 10 minutes to do it using my current configuration.</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>From the comments: It seems that iText can extract the text of multiple rectangles on the same page in one pass, something that can improve the performance (batched operations tend to be more efficient), but how?</p>
  
  <p><strong>MORE DETAILS!</strong></p>
  
  <p>My goal is to extract data from a PDF with multiple pages. Each page has the same layout: a table with rows and columns.</p>
  
  <p>Currently, I'm using the method above to extract the text of each rectangle. But, as you see, the extraction isn't batched. It's only a rectangle at a time. How could I extract all the rectangles of a page in a single pass?</p>