ProjectLensAI / tools /pdf_parser.py
prashant
Initial commit
ecb69bb
Raw History Blame Contribute Delete
395 Bytes
from PyPDF2 import PdfReader
def extract_text_from_pdf(file_path: str) -> str:
text_chunks = []
try:
reader = PdfReader(file_path)
for page in reader.pages:
page_text = page.extract_text() or ""
text_chunks.append(page_text)
return "\n".join(text_chunks).strip()
except Exception as e:
return f"Could not parse PDF: {str(e)}"