import pdfplumber import streamlit as st from io import BytesIO # Import BytesIO def ExtractPDFText(pdf): content = "" pdf_bytes = pdf.read() try: # Using pdfplumber to read the PDF bytes with pdfplumber.open(BytesIO(pdf_bytes)) as pdf_document: # Iterate through pages and extract text for page in pdf_document.pages: text = page.extract_text() content += text if text else "" except Exception as e: st.error(f"Error extracting text from PDF: {e}") return content