-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathpdfreader.py
More file actions
88 lines (54 loc) · 1.44 KB
/
Copy pathpdfreader.py
File metadata and controls
88 lines (54 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import sys
import pyttsx3
import PyPDF2
path = sys.argv[1]
# files = open(path,'r')
# matter = files.read()
# print (matter)
pdfFileObj = open(path, 'rb')
pdfReader = PyPDF2.PdfFileReader(pdfFileObj)
a = pdfReader.numPages
print(a)
# marker for while loop
x = 1
# user answer collector
c = 1
# Reads the PDF
def read(page):
"""
read pdf and print content of specified page
:param page: str or int, page to read
:return: None
"""
page_content = pdfReader.getPage(int(page))
b = page_content.extractText()
print(b)
engine = pyttsx3.init()
rate = engine.getProperty('rate')
engine.setProperty('rate', rate - 50)
engine.say(b)
engine.say("Page number " + str(page) + " is completed")
engine.runAndWait()
engine.stop()
# The main code
while (x):
page = input("Enter the page number to read :")
read(page)
c = int(input("Do you want to continue? (1)Yes (2)No"))
if c == 2:
x = 0
print("Thank you")
# engine = pyttsx3.init()
# rate = engine.getProperty('rate')
# engine.setProperty('rate', rate-50)
# engine.say(matter)
# engine.runAndWait()
# engine.stop()
# engine.say('The quick brown fox jumped over the lazy dog.')
# pdfFileObj = open('/home/naveentata/Downloads/0132678209.pdf', 'rb')
# pdfReader = PyPDF2.PdfFileReader(pdfFileObj)
# a=pdfReader.numPages
# print(a)
# page_content= pdfReader.getPage(0)
# b = page_content.extractText()
# print(b)