fix: ensure PdfReader is closed (#8636)
This commit is contained in:
parent
e2b3c607f2
commit
5d0abf424c
1 changed files with 1 additions and 2 deletions
|
|
@ -130,8 +130,7 @@ def read_docx_file(file_path: str) -> str:
|
|||
def parse_pdf_to_text(file_path: str) -> str:
|
||||
from pypdf import PdfReader
|
||||
|
||||
with Path(file_path).open("rb") as f:
|
||||
reader = PdfReader(f)
|
||||
with Path(file_path).open("rb") as f, PdfReader(f) as reader:
|
||||
return "\n\n".join([page.extract_text() for page in reader.pages])
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue