Spaces:
Sleeping
Sleeping
| import io | |
| import pypdf | |
| def extract_text_from_pdf(pdf_bytes: bytes) -> str: | |
| """ | |
| Extracts raw text from a PDF using pypdf (runs locally, no API needed). | |
| Returns all pages concatenated. | |
| """ | |
| reader = pypdf.PdfReader(io.BytesIO(pdf_bytes)) | |
| pages = [page.extract_text() or "" for page in reader.pages] | |
| return "\n".join(pages).strip() | |