File size: 436 Bytes
eef90c7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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