find_page_in_pdf.py 405 B

123456789101112131415161718
  1. import PyPDF2
  2. import re
  3. # Open the pdf file
  4. object = PyPDF2.PdfFileReader("iso_documents/ISO8015.PDF")
  5. # Get number of pages
  6. NumPages = object.getNumPages()
  7. # Enter code here
  8. String = "Inhalt"
  9. # Extract text and do the search
  10. for i in range(0, NumPages):
  11. PageObj = object.getPage(i)
  12. Text = PageObj.extractText()
  13. if re.search(String,Text):
  14. print("Pattern Found on Page: " + str(i))