forked from acmpesuecc/Doc-Scan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpdf2text.py
29 lines (25 loc) · 1012 Bytes
/
pdf2text.py
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
import PyPDF2
def pdf2text(c, d):
pdfFileObj1 = open(c, 'rb')
pdfReader1 = PyPDF2.PdfFileReader(pdfFileObj1)
for i in range(pdfReader1.numPages):
pageObj1 = pdfReader1.getPage(i)
pdfFileObj2 = open(d, 'rb')
pdfReader2 = PyPDF2.PdfFileReader(pdfFileObj2)
for i in range(pdfReader2.numPages):
pageObj2 = pdfReader2.getPage(i)
count = 0
l = len((pageObj1.extractText()).split())
for i in range(l):
if (((pageObj1.extractText()).split())[i] == (
(pageObj2.extractText()).split())[i]):
count = count+1
elif (((pageObj1.extractText()).split())[i] != (
(pageObj2.extractText()).split())[i]):
print(((pageObj1.extractText()).split())[
i], ((pageObj2.extractText()).split())[i], "There is a mistake at", i, "word")
rem = l-count
# print("The number of mistakes are : ", rem)
pdfFileObj1.close()
pdfFileObj2.close()
return rem