import pdfplumber def extract_text(pdf_path): chunks = [] with pdfplumber.open(pdf_path) as pdf: for page_num, page in enumerate(pdf.pages, start=1): text = page.extract_text() or "" if text.strip(): chunks.append({ "page": page_num, "type": "text", "content": text }) return chunks