1import PyPDF2
2import re
3
4for k in range(1,100):
5 # open the pdf file
6 object = PyPDF2.PdfFileReader("C:/my_path/file%s.pdf"%(k))
7
8 # get number of pages
9 NumPages = object.getNumPages()
10
11 # define keyterms
12 String = "New York State Real Property Law"
13
14 # extract text and do the search
15 for i in range(0, NumPages):
16 PageObj = object.getPage(i)
17 print("this is page " + str(i))
18 Text = PageObj.extractText()
19 # print(Text)
20 ResSearch = re.search(String, Text)
21 print(ResSearch)