I am trying to search for text in each PDF inside of a directory using itext7. I can figure out how to search just one PDF.
I managed to search one pdf using the below code, how can I make this work for each PDF in a directory?
   public List<int> ReadPdfFile(string fileName, String searchString)
        {
            List<int> pages = new List<int>();
            if (File.Exists(fileName))
            {
                PdfReader pdfReader = new PdfReader(fileName);
                for (int page = 1; page <= pdfReader.NumberOfPages; page++)
                {
                    ITextExtractionStrategy strategy = new SimpleTextExtractionStrategy();
                    string currentPageText = PdfTextExtractor.GetTextFromPage(pdfReader, page, strategy);
                    if (currentPageText.Contains(searchString))
                    {
                        MessageBox.Show("Found COLLIN GRADY");
                    }
                    else
                    {
                        MessageBox.Show("Could not find COLLIN GRADY");
                    }
                }
                pdfReader.Close();
            }
            return pages;
        }
This works, by calling
 ReadPdfFile("C:\\Users\\Billy\\Desktop\\All custom flyers\\ALBANY Ketchup Nov 2018 2.pdf", "COLLIN GRADY");