Skip to content

Commit b20f82c

Browse files
I have fixed PyPDF2 version changes problems. (#2)
1 parent a564fef commit b20f82c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

main.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,23 @@ def extract_text(filepath, progress_var):
1414
# Open the PDF file in read-binary mode
1515
with open(filepath, 'rb') as pdf_file:
1616
# Create a PDF reader object
17-
pdf_reader = PyPDF2.PdfFileReader(pdf_file)
17+
pdf_reader = PyPDF2.PdfReader(pdf_file)
1818

1919
# Create an empty string to store the text
2020
text = ''
2121

2222
# Loop through each page in the PDF file
23-
for page_num in range(pdf_reader.getNumPages()):
23+
for page_num in range(len(pdf_reader.pages)):
2424
# Update the progress bar
2525
progress_var.set(page_num + 1)
2626
root.update_idletasks()
2727
root.update()
2828

2929
# Get the page object
30-
page_obj = pdf_reader.getPage(page_num)
30+
page_obj = pdf_reader.pages[page_num]
3131

3232
# Extract the text from the page
33-
page_text = page_obj.extractText()
33+
page_text = page_obj.extract_text()
3434

3535
# Add the text to the string
3636
text += page_text

0 commit comments

Comments
 (0)