Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions pdfreader.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
import sys
import pyttsx3
import PyPDF2
import sys #importing sys module
import pyttsx3 #importing pytttsx3 module
import PyPDF2#importing PyPDF2 module

path = sys.argv[1]
path = sys.argv[1] #taking command line arguments from the terminal

#files = open(path,'r')

#matter = files.read()
#print (matter)

pdfFileObj = open(path, 'rb')
pdfFileObj = open(path, 'rb') # creating a Pdf file object from the given path in read binary mode
pdfReader = PyPDF2.PdfFileReader(pdfFileObj)
a=pdfReader.numPages
print(a)
x=1
c=1

#Reads the PDF

def read(page):

def read(page):
"""
Function to read a particular page in a pdf
"""
page_content= pdfReader.getPage(int(page))
b = page_content.extractText()
b = page_content.extractText() #using module function extractText() to read the entire page data in string format
print(b)
engine = pyttsx3.init()
rate = engine.getProperty('rate')
Expand All @@ -31,12 +32,12 @@ def read(page):
engine.runAndWait()
engine.stop()

# The main code
#Client code to read user given page number from a pdf
while(x):
page = input("Enter the page number to read :")

read(page)
c=int(input("Do you want to continue? (1)Yess (2)No"))
c=int(input("Do you want to continue? (1)Yes (2)No"))
if(c==2):
x=0
print("Thank you")
Expand Down