-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Labels
PdfReaderThe PdfReader component is affectedThe PdfReader component is affected
Description
Explanation
Make PdfReader more pythonic by using the 'with' 'as' context.
Code Example
from PyPDF2 import PdfReader
total_text = ""
pdf_file_path = "example/path" # Replace with your PDF file path
with PdfReader(pdf_file_path) as reader:
total_text = '\n\n'.join([page.extract_text() for page in reader.pages])
Error trace back
Traceback (most recent call last):
File "pdfotxt.py", line 21, in
with PdfReader(pdf_file_path) as reader:
AttributeError: enter
Metadata
Metadata
Assignees
Labels
PdfReaderThe PdfReader component is affectedThe PdfReader component is affected