HealthCare-API / api /services /document_service.py
ryanxely's picture
KPI extraction
9b0ce22
Raw
History Blame Contribute Delete
376 Bytes
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()