Spaces:
Build error
Build error
Download tools/pdf_parser.py from prashantpatil3299/ProjectLensAI: direct link, hf CLI and curl.
- Browser
- Download file 395 Bytes
-
https://huggingface.co/spaces/prashantpatil3299/ProjectLensAI/resolve/main/tools/pdf_parser.py
- Command line
-
hf download hf://spaces/prashantpatil3299/ProjectLensAI/tools/pdf_parser.py
-
curl -L -o pdf_parser.py https://huggingface.co/spaces/prashantpatil3299/ProjectLensAI/resolve/main/tools/pdf_parser.py
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)}" |