Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # https://stackoverflow.com/questions/17098675/searching-text-in-a-pdf-using-python
- #
- # import packages
- import PyPDF2
- import re
- # open the pdf file
- object = PyPDF2.PdfFileReader("test.pdf")
- # get number of pages
- NumPages = object.getNumPages()
- # define keyterms
- String = "Social"
- # 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)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement