title: Trying to loop through multiple PDF files and extract text between two search criteria
body: <p>I am trying to look at multiple PDF files, look at the text of each, and extract paragraphs between (start) 'NOTE 1- ORGANIZATION' and 'NOTE 2- ORGANIZATION' (end).  Each file has different text in this place, and I want to print each paragraph from each file, or save the paragraph to a text file.  </p>
  
  <p>Below, I put together a small script that opens one file, finds one string of text, and prints the page that the text is found on.  This is a good start, I think, but I really want to loop through many PDF files, look for a specific body of text, and save everything that is found to a single text file. </p>
  
  <pre><code>import PyPDF2
  import re
  
  # open the pdf file
  object = PyPDF2.PdfFileReader("C:/my_path/file1.pdf")
  
  # get number of pages
  NumPages = object.getNumPages()
  
  # define keyterms
  String = "New York State Real Property Law"
  
  # extract text and do the search
  for i in range(0, NumPages):
      PageObj = object.getPage(i)
      print("this is page " + str(i)) 
      Text = PageObj.extractText() 
      # print(Text)
      ResSearch = re.search(String, Text)
      print(ResSearch)
  </code></pre>
  
  <p>Any insights into solving this problem are greatly appreciated!</p>