Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

search for a word in pdf using python

import PyPDF2
import re

# Open the pdf file
object = PyPDF2.PdfFileReader(r"C:TEST.pdf")

# Get number of pages
NumPages = object.getNumPages()

# Enter code here
String = "Enter_the_text_to_Search_here"

# Extract text and do the search
for i in range(0, NumPages):
    PageObj = object.getPage(i)
    Text = PageObj.extractText()
    if re.search(String,Text):
         print("Pattern Found on Page: " + str(i))
Comment

PREVIOUS NEXT
Code Example
Python :: transform data frame in list 
Python :: import discord python 
Python :: semicolon in python 
Python :: how to create python environment 
Python :: python makedir 
Python :: python convert input into lowercase 
Python :: cv2 rotate image 
Python :: __str__ method python 
Python :: time difference between two datetime.time 
Python :: pandas resample groupby 
Python :: split list in pd dataframe into rows 
Python :: split at first occurrence python 
Python :: convert .py to .ipynb file 
Python :: hash table in python 
Python :: how to clear dictionary in python 
Python :: get weekday from date python 
Python :: all() python 
Python :: tryexept in python 
Python :: numpy.sign() in Python 
Python :: django oauth toolkit permanent access token 
Python :: live server python 
Python :: python save button 
Python :: one liner if else replacement in python 
Python :: openai gym random action 
Python :: pandas dataframe sort by column 
Python :: Python - How To Check if a String Contains Word 
Python :: python change directory to previous 
Python :: numpy dot product 
Python :: how to add python interpreter in vscode 
Python :: hungry chef 
ADD CONTENT
Topic
Content
Source link
Name
4+1 =